io

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true ]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0 ]; edge [color=lightslategrey, penwidth=1 ]; subgraph "cluster_uqbar.graphs.graphers" { graph [label="uqbar.graphs.graphers"]; node [color=3]; "uqbar.graphs.graphers.Grapher" [label=Grapher]; } subgraph "cluster_abjad.io" { graph [label="abjad.io"]; node [color=1]; "abjad.io.AbjadGrapher" [URL="../api/abjad/io.html#abjad.io.AbjadGrapher", color=black, fontcolor=white, label="Abjad\nGrapher", target=_top]; "abjad.io.Illustrator" [URL="../api/abjad/io.html#abjad.io.Illustrator", color=black, fontcolor=white, label=Illustrator, target=_top]; "abjad.io.LilyPondIO" [URL="../api/abjad/io.html#abjad.io.LilyPondIO", color=black, fontcolor=white, label="Lily\nPond\nIO", target=_top]; "abjad.io.LilyPondIO" -> "abjad.io.Illustrator" [minlen=1]; "abjad.io.Player" [URL="../api/abjad/io.html#abjad.io.Player", color=black, fontcolor=white, label=Player, target=_top]; "abjad.io.LilyPondIO" -> "abjad.io.Player" [minlen=2]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjad.io.LilyPondIO"; "builtins.object" -> "uqbar.graphs.graphers.Grapher" [minlen=1]; "uqbar.graphs.graphers.Grapher" -> "abjad.io.AbjadGrapher" [minlen=1]; }


Classes

AbjadGrapher

Abjad grapher.

Illustrator

Illustrator.

LilyPondIO

LilyPond IO.

Player

Player.

class abjad.io.AbjadGrapher(graphable, format_='pdf', layout='dot')[source]

Abjad grapher.


Attributes Summary

get_output_directory

open_output_path


Special methods

(Grapher).__call__()

Call self as a function.


Methods

(Grapher).get_format() str
(Grapher).get_layout() str
(Grapher).get_openable_paths(format_, output_paths) Generator[Path, None, None]
overridden get_output_directory() Path[source]
(Grapher).get_render_command(format_, input_path, layout) str
(Grapher).get_render_directory()
(Grapher).get_render_prefix(string) str
(Grapher).get_string() str
(Grapher).migrate_assets(render_prefix, render_directory, output_directory) Sequence[Path]
overridden open_output_path(output_path)[source]
(Grapher).persist_log(string, input_path)
(Grapher).persist_string(string, input_path)
(Grapher).run_command(command: str) Tuple[str, int]
class abjad.io.Illustrator(illustrable, *, flags=None, output_directory=None, render_prefix=None, should_copy_stylesheets=False, should_open=True, should_persist_log=True, string=None, **keywords)[source]

Illustrator.


Attributes Summary

get_openable_paths


Special methods

(LilyPondIO).__call__()

Call self as a function.


Methods

(LilyPondIO).copy_stylesheets(render_directory)
(LilyPondIO).get_lilypond_path()
overridden get_openable_paths(output_paths) Iterator[Path][source]
(LilyPondIO).get_output_directory() Path
(LilyPondIO).get_render_command(input_path, lilypond_path) str
(LilyPondIO).get_render_directory()
(LilyPondIO).get_render_prefix(string) str
(LilyPondIO).get_string() str
(LilyPondIO).get_stylesheets_directories() list[Path]
(LilyPondIO).migrate_assets(render_prefix, render_directory, output_directory) Sequence[Path]
(LilyPondIO).open_output_path(output_path)
(LilyPondIO).persist_log(string, input_path)
(LilyPondIO).persist_string(string, input_path)
(LilyPondIO).run_command(command)
class abjad.io.LilyPondIO(illustrable, *, flags=None, output_directory=None, render_prefix=None, should_copy_stylesheets=False, should_open=True, should_persist_log=True, string=None, **keywords)[source]

LilyPond IO.


Attributes Summary

__call__

Call self as a function.

copy_stylesheets

get_lilypond_path

get_openable_paths

get_output_directory

get_render_command

get_render_directory

get_render_prefix

get_string

get_stylesheets_directories

migrate_assets

open_output_path

persist_log

persist_string

run_command


Special methods

overridden __call__()[source]

Call self as a function.


Methods

copy_stylesheets(render_directory)[source]
get_lilypond_path()[source]
get_openable_paths(output_paths: Iterable[Path]) Iterator[Path][source]
get_output_directory() Path[source]
get_render_command(input_path, lilypond_path) str[source]
get_render_directory()[source]
get_render_prefix(string) str[source]
get_string() str[source]
get_stylesheets_directories() list[Path][source]
migrate_assets(render_prefix, render_directory, output_directory) Sequence[Path][source]
open_output_path(output_path)[source]
persist_log(string, input_path)[source]
persist_string(string, input_path)[source]
run_command(command)[source]
class abjad.io.Player(illustrable, *, flags=None, output_directory=None, render_prefix=None, should_copy_stylesheets=False, should_open=True, should_persist_log=True, string=None, **keywords)[source]

Player.


Attributes Summary

get_openable_paths

get_string


Special methods

(LilyPondIO).__call__()

Call self as a function.


Methods

(LilyPondIO).copy_stylesheets(render_directory)
(LilyPondIO).get_lilypond_path()
overridden get_openable_paths(output_paths) Iterator[Path][source]
(LilyPondIO).get_output_directory() Path
(LilyPondIO).get_render_command(input_path, lilypond_path) str
(LilyPondIO).get_render_directory()
(LilyPondIO).get_render_prefix(string) str
overridden get_string() str[source]
(LilyPondIO).get_stylesheets_directories() list[Path]
(LilyPondIO).migrate_assets(render_prefix, render_directory, output_directory) Sequence[Path]
(LilyPondIO).open_output_path(output_path)
(LilyPondIO).persist_log(string, input_path)
(LilyPondIO).persist_string(string, input_path)
(LilyPondIO).run_command(command)

Functions

compare_files

Compares file path_1 to file path_2.

count_function_calls

Counts function calls required to execute argument.

execute_file

Executes file path.

execute_string

Executes string.

find_executable

Finds executable name.

graph

Graphs argument.

make_subprocess

Makes Popen instance.

open_file

Opens file_path.

open_last_log

Opens LilyPond log file in operating system-specific text editor.

profile

Profiles string.

run_command

Runs command in subprocess.

run_lilypond

Runs LilyPond on ly_path.

show

Shows argument.

spawn_subprocess

Spawns subprocess and runs command.

abjad.io.compare_files(path_1, path_2)[source]

Compares file path_1 to file path_2.

For all file types:

* Performs line-by-line comparison
* Discards blank lines

For LilyPond files, additionally:

* Discards any LilyPond version statements
* Discards any lines beginning with ``%``

Returns true when files compare the same and false when files compare differently.

abjad.io.count_function_calls(argument: str, *, global_context: dict | None = None, local_context: dict | None = None, fixed_point: bool = True) int[source]

Counts function calls required to execute argument.

abjad.io.execute_file(path: str | None = None, *, attribute_names: tuple[str] | None = None) tuple[str] | None[source]

Executes file path.

Returns attribute_names from file.

abjad.io.execute_string(string: str, *, attribute_names: tuple[str] | None = None, local_namespace: dict | None = None)[source]

Executes string.

>>> string = "foo = 23"
>>> attribute_names = ("foo", "bar")
>>> abjad.io.execute_string(
...     string,
...     attribute_names=attribute_names,
... )
(23, None)

Returns attribute_names from executed string.

abjad.io.find_executable(name: str, *, flags: int = 1) list[Path][source]

Finds executable name.

Similar to Unix which command.

Returns list of zero or more full paths to name.

abjad.io.graph(graphable, format_='pdf', layout='dot', return_timing=False, **keywords)[source]

Graphs argument.

Graphs staff:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> abjad.graph(staff)  

Graphs rhythm tree:

>>> rtm_syntax = "(3 ((2 (2 1)) 2))"
>>> parser = abjad.rhythmtrees.RhythmTreeParser()
>>> rhythm_tree = parser(rtm_syntax)[0]
>>> abjad.graph(rhythm_tree)  

Opens image in default image viewer.

abjad.io.make_subprocess(command: str) Popen[source]

Makes Popen instance.

Defined equal to:

process = subprocess.Popen(

command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, )

Redirects stderr to stdout.

abjad.io.open_file(file_path: str, *, application: str | None = None, line_number: int | None = None, test: bool = False)[source]

Opens file_path.

Uses application when application is not none.

Uses Abjad configuration file text_editor when application is none.

Takes best guess at operating system-specific file opener when both application and Abjad configuration file text_editor are none.

Respects line_number when file_path can be opened with text editor.

abjad.io.open_last_log() None[source]

Opens LilyPond log file in operating system-specific text editor.

abjad.io.profile(string: str, *, global_context: dict | None = None, line_count: int = 12, local_context: dict | None = None, print_callers: bool = False, print_callees: bool = False, sort_by: str = 'cumulative', strip_dirs: bool = True) str | None[source]

Profiles string.

>>> string = 'abjad.Staff("c8 c8 c8 c8 c8 c8 c8 c8")'
>>> result = abjad.io.profile(string, global_context=globals())

Then print result.

Wraps Python’s built-in cProfile module.

Set sort_by to 'cumulative', 'time' or 'calls'.

See Python’s docs for more information.

abjad.io.run_command(command: str) list[str][source]

Runs command in subprocess.

Returns list of strings read from subprocess stdout.

abjad.io.run_lilypond(ly_path: str, *, flags: str = '', lilypond_log_file_path: Path | None = None) int[source]

Runs LilyPond on ly_path.

Writes redirected output of Unix date to top line of LilyPond log file.

Then appends redirected output of LilyPond output to the LilyPond log file.

abjad.io.show(illustrable, *, flags: str = '', return_timing: bool = False, **keywords)[source]

Shows argument.

Shows note:

>>> note = abjad.Note("c'4")
>>> abjad.show(note)  

Shows staff:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> abjad.show(staff)  

Makes LilyPond input files and output PDF.

Writes LilyPond input file and output PDF to Abjad output directory.

Opens output PDF.

Returns none when return_timing is false.

Returns pair of abjad_formatting_time and lilypond_rendering_time when return_timing is true.

abjad.io.spawn_subprocess(command: str) int[source]

Spawns subprocess and runs command.

The function is basically a reimplementation of the deprecated os.system() using Python’s subprocess module.

Redirects stderr to stdout.