abjad.io
|
Compares file |
|
Counts function calls required to execute |
|
Executes file |
|
Executes |
|
Finds executable |
|
Graphs |
|
Makes Popen instance. |
|
Opens |
Opens LilyPond log file in operating system-specific text editor. |
|
|
Profiles |
|
Runs command in subprocess. |
|
Runs LilyPond on |
|
Shows |
|
Abjad grapher. |
|
Illustrator. |
|
LilyPond IO. |
|
Player. |
- abjad.io.compare_files(path_1, path_2)[source]
Compares file
path_1to filepath_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, only_one_time: bool = False) 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_namesfrom file.
- abjad.io.execute_string(string: str, *, attribute_names: tuple[str] | None = None, local_namespace: dict | None = None) tuple | None[source]
Executes
string.Returns
attribute_namesfrom executed string.>>> string = "foo = 23" >>> attribute_names = ("foo", "bar") >>> abjad.io.execute_string( ... string, ... attribute_names=attribute_names, ... ) (23, None)
- abjad.io.find_executable(name: str, *, flags: int = 1) list[Path][source]
Finds executable
name.Similar to Unix
whichcommand.Returns list of zero or more full paths to
name.
- abjad.io.graph(graphable, format_='pdf', layout='dot', return_timing=False, **keywords) tuple[float, float] | None[source]
Graphs
argument.Opens image in default image viewer.
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)
- abjad.io.make_subprocess(command: str) Popen[source]
Makes Popen instance.
Redirects stderr to stdout.
Defined equal to:
process = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.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
applicationwhenapplicationis not none.Uses Abjad configuration file
text_editorwhenapplicationis none.Takes best guess at operating system-specific file opener when both
applicationand Abjad configuration filetext_editorare none.Respects
line_numberwhenfile_pathcan 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, *, do_not_strip_dirs: bool = False, 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') str[source]
Profiles
string.Wraps Python’s built-in
cProfilemodule. Setsort_byto"cumulative","time","calls". See the Python documentation for more information.>>> string = 'abjad.Staff("c8 c8 c8 c8 c8 c8 c8 c8")' >>> result = abjad.io.profile(string, global_context=globals())
- 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
dateto 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
illustrable.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_timingis false.Returns pair of
abjad_formatting_timeandlilypond_rendering_timewhenreturn_timingis true.Shows note:
>>> note = abjad.Note("c'4") >>> abjad.show(note)
- class abjad.io.AbjadGrapher(graphable, format_='pdf', layout='dot')[source]
Abjad grapher.
Gets Abjad output directory.
open_output_path(output_path)Opens
output_path.
- 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.
openable_paths(output_paths)Gets openable paths.
- 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.
Gets Abjad output directory.
copy_stylesheets(render_directory)Copies stylesheets.
Gets LilyPond format string.
Gets LilyPond path.
migrate_assets(render_prefix, ...)Migrates assets.
open_output_path(output_path)Opens
output_path.openable_paths(output_paths)Gets openable paths.
persist_log(string, input_path)Persists log
stringtoinput_path.persist_string(string, input_path)Persists
stringtoinput_path.render_command(input_path, lilypond_path)Gets render command.
Gets render directory.
run_command(command)Runs
command.Gets stylesheets directories.
timestamp_checksum_render_prefix(string)Gets timestamp-checksum render prefix.
- 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.
Gets LilyPond format string.
openable_paths(output_paths)Gets openable paths.