PersistenceAgent

class agenttools.PersistenceAgent(client=None)

Persistence agent.

>>> import abjad
>>> staff = abjad.Staff("c'4 e'4 d'4 f'4")
>>> show(staff) 
>>> abjad.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 = abjad.Staff("c'4 e'4 d'4 f'4")
>>> for x in persist(staff).as_ly('~/example.ly'): 
...     x
... 
'/Users/joberholtzer/example.ly'
0.002554655075073242

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 = abjad.Staff("c'4 e'4 d'4 f'4")
>>> for x in persist(staff).as_midi(): 
...     x
... 
'/Users/joberholtzer/.abjad/output/0809.midi'
0.003201007843017578
0.5239040851593018

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

PersistenceAgent.as_module(module_file_path, object_name)

Persists client as Python module.

>>> timespans = abjad.TimespanList([
...     abjad.Timespan(0, 1),
...     abjad.Timespan(2, 4),
...     abjad.Timespan(6, 8),
...     ])
>>> abjad.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 = abjad.Staff("c'4 e'4 d'4 f'4")
>>> for x in persist(staff).as_pdf(): 
...     x
... 
'/Users/joberholtzer/.abjad/output/0810.pdf'
0.0034112930297851562
0.6103191375732422
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 = abjad.Staff()
>>> measure = abjad.Measure((4, 4), "c'4 d'4 e'4 f'4")
>>> command = abjad.LilyPondCommand('break', 'after')
>>> abjad.attach(command, measure[-1])
>>> staff.extend(measure * 200)
>>> result = persist(staff).as_png() 
>>> for x in result[0]: 
...     x
... 
'/Users/joberholtzer/.abjad/output/0811-page1.png'
'/Users/joberholtzer/.abjad/output/0811-page2.png'
'/Users/joberholtzer/.abjad/output/0811-page3.png'
'/Users/joberholtzer/.abjad/output/0811-page4.png'
'/Users/joberholtzer/.abjad/output/0811-page5.png'
'/Users/joberholtzer/.abjad/output/0811-page6.png'
'/Users/joberholtzer/.abjad/output/0811-page7.png'
'/Users/joberholtzer/.abjad/output/0811-page8.png'
'/Users/joberholtzer/.abjad/output/0811-page9.png'
'/Users/joberholtzer/.abjad/output/0811-page10.png'
'/Users/joberholtzer/.abjad/output/0811-page11.png'
'/Users/joberholtzer/.abjad/output/0811-page12.png'
'/Users/joberholtzer/.abjad/output/0811-page13.png'
'/Users/joberholtzer/.abjad/output/0811-page14.png'
'/Users/joberholtzer/.abjad/output/0811-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.