io
Classes
Abjad grapher. |
|
Illustrator. |
|
LilyPond IO. |
|
Player. |
- class abjad.io.AbjadGrapher(graphable, format_='pdf', layout='dot')[source]
Abjad grapher.
Attributes Summary
Special methods
-
(
Grapher
).__call__() Call self as a function.
Methods
-
(
Grapher
).get_render_directory()
-
(
Grapher
).persist_log(string, input_path)
-
(
Grapher
).persist_string(string, input_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.
Attributes Summary
Special methods
-
(
LilyPondIO
).__call__() Call self as a function.
Methods
-
(
LilyPondIO
).copy_stylesheets(render_directory)
-
(
LilyPondIO
).get_lilypond_path()
-
(
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 self as a function.
Special methods
Methods
- 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
Special methods
-
(
LilyPondIO
).__call__() Call self as a function.
Methods
-
(
LilyPondIO
).copy_stylesheets(render_directory)
-
(
LilyPondIO
).get_lilypond_path()
-
(
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_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
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 |
|
Spawns subprocess and runs |
- abjad.io.compare_files(path_1, path_2)[source]
Compares file
path_1
to 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, 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
whenapplication
is not none.Uses Abjad configuration file
text_editor
whenapplication
is none.Takes best guess at operating system-specific file opener when both
application
and Abjad configuration filetext_editor
are none.Respects
line_number
whenfile_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
andlilypond_rendering_time
whenreturn_timing
is true.