SchemeMoment

class schemetools.SchemeMoment(*args, **kwargs)

A LilyPond scheme moment.

Initializes with two integers:

>>> moment = schemetools.SchemeMoment(1, 68)
>>> moment
SchemeMoment(1, 68)

Scheme moments are immutable.

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.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_schemetools { graph [label=schemetools]; "abjad.tools.schemetools.Scheme.Scheme" [color=3, group=2, label=Scheme, shape=box]; "abjad.tools.schemetools.SchemeMoment.SchemeMoment" [color=black, fontcolor=white, group=2, label=<<B>SchemeMoment</B>>, shape=box, style="filled, rounded"]; "abjad.tools.schemetools.Scheme.Scheme" -> "abjad.tools.schemetools.SchemeMoment.SchemeMoment"; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.schemetools.Scheme.Scheme"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

duration Duration of scheme moment.
force_quotes Is true when quotes should be forced in output.
format_embedded_scheme_value(value[, ...]) Formats value as an embedded Scheme value.
format_scheme_value(value[, force_quotes, ...]) Formats value as Scheme would.
quoting Gets Scheme quoting string.
verbatim Is true when formatting should format value absolutely verbatim.
__copy__(\*args) Copies Abjad value object.
__eq__(arg) Is true when arg is a scheme moment with the same value as that of this scheme moment.
__format__([format_specification]) Formats scheme.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes scheme moment.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(arg) Is true when arg is a scheme moment with value greater than that of this scheme moment.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.
__str__() String representation of scheme object.

Read-only properties

SchemeMoment.duration

Duration of scheme moment.

>>> scheme_moment = schemetools.SchemeMoment(1, 68)
>>> scheme_moment.duration
Duration(1, 68)

Returns duration.

(Scheme).force_quotes

Is true when quotes should be forced in output. Otherwise false.

Returns true or false.

(Scheme).quoting

Gets Scheme quoting string.

Returns string.

(Scheme).verbatim

Is true when formatting should format value absolutely verbatim. Whitespace, quotes, and all other parts of value are left intact.

Defaults to false.

Set to true or false.

Returns true or false.

Class & static methods

(Scheme).format_embedded_scheme_value(value, force_quotes=False)

Formats value as an embedded Scheme value.

(Scheme).format_scheme_value(value, force_quotes=False, verbatim=False)

Formats value as Scheme would.

Example 1. Some basic values:

>>> schemetools.Scheme.format_scheme_value(1)
'1'
>>> schemetools.Scheme.format_scheme_value('foo')
'foo'
>>> schemetools.Scheme.format_scheme_value('bar baz')
'"bar baz"'
>>> schemetools.Scheme.format_scheme_value([1.5, True, False])
'(1.5 #t #f)'

Example 2. Strings without whitespace can be forcibly quoted via the force_quotes keyword:

>>> schemetools.Scheme.format_scheme_value(
...     'foo',
...     force_quotes=True,
...     )
'"foo"'

Example 3. Set verbatim to true to format value exactly (with only hash preprended):

>>> string = '(lambda (grob) (grob-interpret-markup grob'
>>> string += r' #{ \markup \musicglyph #"noteheads.s0harmonic" #}))'
>>> schemetools.Scheme.format_scheme_value(string, verbatim=True)
'(lambda (grob) (grob-interpret-markup grob #{ \\markup \\musicglyph #"noteheads.s0harmonic" #}))'

Example 4. Hash symbols in strings will result in quoted output unless verbatim is True, in order to prevent LilyPond parsing errors:

>>> string = '#1-finger'
>>> schemetools.Scheme.format_scheme_value(string)
'"#1-finger"'
>>> schemetools.Scheme.format_scheme_value(string, verbatim=True)
'#1-finger'

Returns string.

Special methods

(AbjadValueObject).__copy__(*args)

Copies Abjad value object.

Returns new Abjad value object.

SchemeMoment.__eq__(arg)

Is true when arg is a scheme moment with the same value as that of this scheme moment.

>>> moment == schemetools.SchemeMoment(1, 68)
True

Otherwise false.

>>> moment == schemetools.SchemeMoment(1, 54)
False

Returns true or false.

(Scheme).__format__(format_specification='')

Formats scheme.

Set format_specification to ‘’‘, ‘lilypond’ or 'storage'. Interprets ‘’ equal to ‘lilypond’.

Example 1. Scheme LilyPond format:

>>> scheme = schemetools.Scheme('foo')
>>> format(scheme)
'#foo'

Example 2. Scheme storage format:

>>> print(format(scheme, 'storage'))
schemetools.Scheme(
    'foo'
    )

Returns string.

SchemeMoment.__ge__(other, NotImplemented=NotImplemented)

Return a >= b. Computed by @total_ordering from (not a < b).

SchemeMoment.__gt__(other, NotImplemented=NotImplemented)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

SchemeMoment.__hash__()

Hashes scheme moment.

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

Returns integer.

SchemeMoment.__le__(other, NotImplemented=NotImplemented)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

SchemeMoment.__lt__(arg)

Is true when arg is a scheme moment with value greater than that of this scheme moment.

>>> moment < schemetools.SchemeMoment(1, 32)
True

Otherwise false:

>>> moment < schemetools.SchemeMoment(1, 78)
False

Returns true or false.

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

(Scheme).__str__()

String representation of scheme object.

Returns string.