Block

class lilypondfiletools.Block(name='score')

A LilyPond file block.

>>> block = lilypondfiletools.Block(name='paper')
>>> block.left_margin = lilypondfiletools.LilyPondDimension(2, 'cm')
>>> block.right_margin = lilypondfiletools.LilyPondDimension(2, 'cm')
>>> block
<Block(name='paper')>
>>> print(format(block))
\paper {
    left-margin = 2\cm
    right-margin = 2\cm
}
>>> block = lilypondfiletools.Block(name='score')
>>> markup = Markup('foo')
>>> block.items.append(markup)
>>> block
<Block(name='score')>
>>> print(format(block))
\score {
    {
        \markup { foo }
    }
}

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

Bases

Attribute summary

items Gets items in block.
name Gets name of block.
__eq__(argument) Is true when ID of argument equals ID of Abjad object.
__format__([format_specification]) Formats block.
__getitem__(name) Gets item with name.
__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

Block.items

Gets items in block.

>>> block = lilypondfiletools.Block(name='score')
>>> markup = Markup('foo')
>>> block.items.append(markup)
>>> block.items
[Markup(contents=['foo'])]

Returns list.

Block.name

Gets name of block.

>>> block = lilypondfiletools.Block(name='score')
>>> markup = Markup('foo')
>>> block.items.append(markup)
>>> block.name
'score'

Returns string.

Special methods

(AbjadObject).__eq__(argument)

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

Returns true or false.

Block.__format__(format_specification='')

Formats block.

Returns string.

Block.__getitem__(name)

Gets item with name.

Gets score with name 'Red Example Score' in score block:

>>> block = lilypondfiletools.Block(name='score')
>>> score = Score(name='Red Example Score')
>>> block.items.append(score)
>>> block['Red Example Score']
Score(is_simultaneous=True)

Returns item.

Raises key error when no item with name is found.

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