PersistenceAgent

class agenttools.PersistenceAgent(client=None)

Persistence agent.

>>> staff = Staff("c'4 e'4 d'4 f'4")
>>> show(staff) 
>>> persist(staff)
PersistenceAgent(client=Staff("c'4 e'4 d'4 f'4"))

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_agenttools { graph [label=agenttools]; "abjad.tools.agenttools.PersistenceAgent.PersistenceAgent" [color=black, fontcolor=white, group=1, label=<<B>PersistenceAgent</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=3, group=2, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.agenttools.PersistenceAgent.PersistenceAgent"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

as_ly([ly_file_path, illustrate_function]) Persists client as LilyPond file.
as_midi([midi_file_path, remove_ly]) Persists client as MIDI file.
as_module(module_file_path, object_name) Persists client as Python module.
as_pdf([pdf_file_path, illustrate_function, ...]) Persists client as PDF.
as_png([png_file_path, remove_ly, ...]) Persists client as PNG.
client Client of persistence agent.
__eq__(argument) Is true when ID of argument equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad object.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

PersistenceAgent.client

Client of persistence agent.

Returns selection or component.

Methods

PersistenceAgent.as_ly(ly_file_path=None, illustrate_function=None, **keywords)

Persists client as LilyPond file.

Autogenerates file path when ly_file_path is none.

>>> staff = Staff("c'4 e'4 d'4 f'4")
>>> for x in persist(staff).as_ly('~/example.ly'): 
...     x
... 
'/Users/joberholtzer/example.ly'
0.002112150192260742

Returns output path and elapsed formatting time when LilyPond output is written.

PersistenceAgent.as_midi(midi_file_path=None, remove_ly=False, **keywords)

Persists client as MIDI file.

Autogenerates file path when midi_file_path is none.

>>> staff = Staff("c'4 e'4 d'4 f'4")
>>> for x in persist(staff).as_midi(): 
...     x
... 
'/Users/joberholtzer/.abjad/output/0745.midi'
0.0027048587799072266
0.6250159740447998

Returns output path, elapsed formatting time and elapsed rendering time.

PersistenceAgent.as_module(module_file_path, object_name)

Persists client as Python module.

>>> timespans = timespantools.TimespanList([
...     timespantools.Timespan(0, 1),
...     timespantools.Timespan(2, 4),
...     timespantools.Timespan(6, 8),
...     ])
>>> persist(timespans).as_module( 
...     '~/example.py',
...     'timespans',
...     )

Returns none.

PersistenceAgent.as_pdf(pdf_file_path=None, illustrate_function=None, remove_ly=False, **keywords)

Persists client as PDF.

Autogenerates file path when pdf_file_path is none.

>>> staff = Staff("c'4 e'4 d'4 f'4")
>>> for x in persist(staff).as_pdf(): 
...     x
... 
'/Users/joberholtzer/.abjad/output/0746.pdf'
0.002535104751586914
0.7351720333099365
True

Returns output path, elapsed formatting time and elapsed rendering time when PDF output is written.

PersistenceAgent.as_png(png_file_path=None, remove_ly=False, illustrate_function=None, **keywords)

Persists client as PNG.

>>> staff = Staff()
>>> measure = Measure((4, 4), "c'4 d'4 e'4 f'4")
>>> command = indicatortools.LilyPondCommand('break', 'after')
>>> attach(command, measure[-1])
>>> staff.extend(measure * 200)
>>> result = persist(staff).as_png() 
>>> for x in result[0]: 
...     x
... 
'/Users/joberholtzer/.abjad/output/0747-page1.png'
'/Users/joberholtzer/.abjad/output/0747-page2.png'
'/Users/joberholtzer/.abjad/output/0747-page3.png'
'/Users/joberholtzer/.abjad/output/0747-page4.png'
'/Users/joberholtzer/.abjad/output/0747-page5.png'
'/Users/joberholtzer/.abjad/output/0747-page6.png'
'/Users/joberholtzer/.abjad/output/0747-page7.png'
'/Users/joberholtzer/.abjad/output/0747-page8.png'
'/Users/joberholtzer/.abjad/output/0747-page9.png'
'/Users/joberholtzer/.abjad/output/0747-page10.png'
'/Users/joberholtzer/.abjad/output/0747-page11.png'
'/Users/joberholtzer/.abjad/output/0747-page12.png'
'/Users/joberholtzer/.abjad/output/0747-page13.png'
'/Users/joberholtzer/.abjad/output/0747-page14.png'
'/Users/joberholtzer/.abjad/output/0747-page15.png'

Autogenerates file path when png_file_path is none.

Returns output path(s), elapsed formatting time and elapsed rendering time.

Special methods

(AbjadObject).__eq__(argument)

Is true when ID of argument equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.