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__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad object.
__ne__(expr) Is true when Abjad object does not equal expr.
__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, **kwargs)

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.0021791458129882812

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

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

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/0532.midi'
0.0027260780334472656
0.4437720775604248

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

PersistenceAgent.as_module(module_file_path, object_name)

Persists client as Python module.

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

Returns none.

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

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/0533.pdf'
0.0025908946990966797
0.5606429576873779
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, **kwargs)

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/0534-page1.png'
'/Users/joberholtzer/.abjad/output/0534-page2.png'
'/Users/joberholtzer/.abjad/output/0534-page3.png'
'/Users/joberholtzer/.abjad/output/0534-page4.png'
'/Users/joberholtzer/.abjad/output/0534-page5.png'
'/Users/joberholtzer/.abjad/output/0534-page6.png'
'/Users/joberholtzer/.abjad/output/0534-page7.png'
'/Users/joberholtzer/.abjad/output/0534-page8.png'
'/Users/joberholtzer/.abjad/output/0534-page9.png'
'/Users/joberholtzer/.abjad/output/0534-page10.png'
'/Users/joberholtzer/.abjad/output/0534-page11.png'
'/Users/joberholtzer/.abjad/output/0534-page12.png'
'/Users/joberholtzer/.abjad/output/0534-page13.png'
'/Users/joberholtzer/.abjad/output/0534-page14.png'
'/Users/joberholtzer/.abjad/output/0534-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__(expr)

Is true when ID of expr 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__(expr)

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

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.