io¶
Classes
Abjad grapher. |
|
Illustrator. |
|
LilyPond IO. |
|
Player. |
- class abjad.io.AbjadGrapher(graphable, format_='pdf', layout='dot')[source]¶
Abjad grapher.
Attributes Summary
- rtype:
Special methods
Methods
- 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()¶ - Return type:
-
(
LilyPondIO
).get_render_command(input_path, lilypond_path)¶ - Return type:
-
(
LilyPondIO
).get_render_directory()¶
-
(
LilyPondIO
).get_render_prefix(string)¶ - Return type:
-
(
LilyPondIO
).get_string()¶ - Return type:
-
(
LilyPondIO
).get_stylesheets_directories()¶
-
(
LilyPondIO
).migrate_assets(render_prefix, render_directory, output_directory)¶
-
(
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.
- rtype:
- rtype:
- rtype:
- rtype:
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
- rtype:
Special methods
-
(
LilyPondIO
).__call__()¶ Call self as a function.
Methods
-
(
LilyPondIO
).copy_stylesheets(render_directory)¶
-
(
LilyPondIO
).get_lilypond_path()¶
-
(
LilyPondIO
).get_output_directory()¶ - Return type:
-
(
LilyPondIO
).get_render_command(input_path, lilypond_path)¶ - Return type:
-
(
LilyPondIO
).get_render_directory()¶
-
(
LilyPondIO
).get_render_prefix(string)¶ - Return type:
-
(
LilyPondIO
).get_stylesheets_directories()¶
-
(
LilyPondIO
).migrate_assets(render_prefix, render_directory, output_directory)¶
-
(
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, *, global_context=None, local_context=None, fixed_point=True)[source]¶
Counts function calls required to execute
argument
.- Return type:
- abjad.io.execute_file(path=None, *, attribute_names=None)[source]¶
Executes file
path
.Returns
attribute_names
from file.
- abjad.io.execute_string(string, *, attribute_names=None, local_namespace=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, *, flags=1)[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)[source]¶
Makes Popen instance.
Defined equal to: :rtype:
Popen
- process = subprocess.Popen(
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, )
Redirects stderr to stdout.
- abjad.io.open_file(file_path, *, application=None, line_number=None, test=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()[source]¶
Opens LilyPond log file in operating system-specific text editor.
- Return type:
- abjad.io.profile(string, *, global_context=None, line_count=12, local_context=None, print_callers=False, print_callees=False, sort_by='cumulative', strip_dirs=True)[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)[source]¶
Runs command in subprocess.
Returns list of strings read from subprocess stdout.
- abjad.io.run_lilypond(ly_path, *, flags='', lilypond_log_file_path=None)[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.
- Return type:
- abjad.io.show(illustrable, return_timing=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.