IOManager

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_abjad.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.IOManager.IOManager" [URL="../api/abjad/system/IOManager.html#abjad.system.IOManager.IOManager", color=black, fontcolor=white, label=IOManager, target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.IOManager.IOManager"; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.system.IOManager.IOManager

Manages Abjad IO.


Attributes Summary

clear_terminal Clears terminal.
count_function_calls Counts function calls required to execute argument.
execute_file Executes file path.
execute_string Executes string.
find_executable Finds executable name.
get_last_output_file_name Gets last output file name in output_directory.
get_next_output_file_name Gets next output file name with file_extension in output_directory.
make_subprocess Makes Popen instance.
open_file Opens file_path.
open_last_log Opens LilyPond log file in operating system-specific text editor.
open_last_ly Opens last LilyPond output file produced by Abjad.
open_last_pdf Opens last PDF generated by Abjad.
profile Profiles argument.
run_command Makes subprocess with command.
run_lilypond Runs LilyPond on ly_path.
save_last_ly_as Saves last LilyPond file created by Abjad as file_path.
save_last_pdf_as Saves last PDF created by Abjad as file_path.
spawn_subprocess Spawns subprocess and runs command.

Special methods

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Class & static methods

static clear_terminal()

Clears terminal.

Runs clear if OS is POSIX-compliant (UNIX / Linux / MacOS).

Runs cls if OS is not POSIX-compliant (Windows).

Returns none.

static count_function_calls(argument, global_context=None, local_context=None, fixed_point=True)

Counts function calls required to execute argument.

Wraps IOManager.profile(argument).

Returns nonnegative integer.

static execute_file(path=None, attribute_names=None)

Executes file path.

Returns attribute_names from file.

static execute_string(string, attribute_names=None, local_namespace=None)

Executes string.

>>> string = 'foo = 23'
>>> attribute_names = ('foo', 'bar')
>>> abjad.IOManager.execute_string(string, attribute_names)
(23, None)

Returns attribute_names from executed string.

static find_executable(name, flags=1)

Finds executable name.

Similar to Unix which command.

>>> abjad.IOManager.find_executable('python3.6') 
['/usr/bin/python3.6']

Returns list of zero or more full paths to name.

static get_last_output_file_name(extension=None, output_directory=None)

Gets last output file name in output_directory.

>>> abjad.IOManager.get_last_output_file_name() 
'6222.ly'

Gets last output file name in Abjad output directory when output_directory is none.

Returns none when output directory contains no output files.

Returns string or none.

static get_next_output_file_name(file_extension='ly', output_directory=None)

Gets next output file name with file_extension in output_directory.

>>> abjad.IOManager.get_next_output_file_name() 
'6223.ly'

Gets next output file name with file_extension in Abjad output directory when output_directory is none.

Returns string.

static make_subprocess(command)

Makes Popen instance.

>>> command = 'echo "hellow world"'
>>> abjad.IOManager.make_subprocess(command)
<subprocess.Popen object at 0x...>

Defined equal to:

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

Redirects stderr to stdout.

static open_file(file_path, application=None, line_number=None)

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.

Returns none.

static open_last_log()

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

Returns none.

static open_last_ly(target=-1)

Opens last LilyPond output file produced by Abjad.

Uses operating-specific text editor.

Set target=-2 to open the next-to-last LilyPond output file produced by Abjad, and so on.

Returns none.

static open_last_pdf(target=-1)

Opens last PDF generated by Abjad.

Abjad writes PDFs to the ~/.abjad/output directory by default.

You may change this by setting the abjad_output_directory variable in the config.py file.

Set target=-2 to open the next-to-last PDF generated by Abjad.

Returns none.

static profile(argument, sort_by='cumulative', line_count=12, strip_dirs=True, print_callers=False, print_callees=False, global_context=None, local_context=None, print_to_terminal=True)

Profiles argument.

>>> argument = 'abjad.Staff("c8 c8 c8 c8 c8 c8 c8 c8")'
>>> abjad.IOManager.profile(
...     argument,
...     global_context=globals(),
...     ) 
Tue Apr  5 20:32:40 2011    _tmp_abj_profile

        2852 function calls (2829 primitive calls) in 0.006 CPU seconds

Ordered by: cumulative time
List reduced from 118 to 12 due to restriction <12>

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.006    0.006 <string>:1(<module>)
        1    0.001    0.001    0.003    0.003 make_notes.py:12(make_not
        1    0.000    0.000    0.003    0.003 Staff.py:21(__init__)
        1    0.000    0.000    0.003    0.003 Context.py:11(__init__)
        1    0.000    0.000    0.003    0.003 Container.py:23(__init__)
        1    0.000    0.000    0.003    0.003 Container.py:271(_initial
        2    0.000    0.000    0.002    0.001 all_are_logical_voice_con
    52    0.001    0.000    0.002    0.000 component_to_logical_voic
        1    0.000    0.000    0.002    0.002 _construct_unprolated_not
        8    0.000    0.000    0.002    0.000 make_tied_note.py:5(make_
        8    0.000    0.000    0.002    0.000 make_tied_leaf.py:5(make_

Wraps the built-in Python cProfile module.

Set argument to any string of Abjad input.

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

Set line_count to any nonnegative integer.

Set strip_dirs to true to strip directory names from output lines.

See the Python docs for more information on the Python profilers.

Returns none when print_to_terminal is false.

Returns string when print_to_terminal is true.

static run_command(command)

Makes subprocess with command.

Runs command.

Displays nothing.

Returns stdout from subprocess.

static run_lilypond(ly_path, flags=None, lilypond_path=None)

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.

Returns none.

static save_last_ly_as(file_path)

Saves last LilyPond file created by Abjad as file_path.

Returns none.

static save_last_pdf_as(file_path)

Saves last PDF created by Abjad as file_path.

Returns none.

static spawn_subprocess(command)

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.

Returns integer exit code.