ContextBlock

class lilypondfiletools.ContextBlock(source_context_name=None, name=None, type_=None, alias=None)

A LilyPond file \context block.

>>> import abjad
>>> block = abjad.ContextBlock(
...     source_context_name='Staff',
...     name='FluteStaff',
...     type_='Engraver_group',
...     alias='Staff',
...     )
>>> block.remove_commands.append('Forbid_line_break_engraver')
>>> block.consists_commands.append('Horizontal_bracket_engraver')
>>> block.accepts_commands.append('FluteUpperVoice')
>>> block.accepts_commands.append('FluteLowerVoice')
>>> block.items.append(r'\accidentalStyle dodecaphonic')
>>> abjad.override(block).beam.positions = (-4, -4)
>>> abjad.override(block).stem.stem_end_position = -6
>>> abjad.setting(block).auto_beaming = False
>>> abjad.setting(block).tuplet_full_length = True
>>> block
<ContextBlock(source_context_name='Staff', name='FluteStaff', type_='Engraver_group', alias='Staff')>
>>> print(format(block))
\context {
    \Staff
    \name FluteStaff
    \type Engraver_group
    \alias Staff
    \remove Forbid_line_break_engraver
    \consists Horizontal_bracket_engraver
    \accepts FluteUpperVoice
    \accepts FluteLowerVoice
    \override Beam.positions = #'(-4 . -4)
    \override Stem.stem-end-position = #-6
    autoBeaming = ##f
    tupletFullLength = ##t
    \accidentalStyle dodecaphonic
}

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=3, group=2, label=Block, shape=box]; "abjad.tools.lilypondfiletools.ContextBlock.ContextBlock" [color=black, fontcolor=white, group=2, label=<<B>ContextBlock</B>>, shape=box, style="filled, rounded"]; "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

accepts_commands Gets arguments of LilyPond \accepts commands.
alias Gets and sets argument of LilyPond \alias command.
consists_commands Gets arguments of LilyPond \consists commands.
items Gets items in context block.
name Gets and sets argument of LilyPond \name command.
remove_commands Gets arguments of LilyPond \remove commands.
source_context_name Gets and sets source context name.
type_ Gets and sets argument of LilyPond \type command.
__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.
__setattr__(name, value) Sets block name to value.

Read-only properties

ContextBlock.accepts_commands

Gets arguments of LilyPond \accepts commands.

>>> block.accepts_commands
['FluteUpperVoice', 'FluteLowerVoice']

Returns list.

ContextBlock.alias

Gets and sets argument of LilyPond \alias command.

>>> block.alias
'Staff'

Returns string or none.

ContextBlock.consists_commands

Gets arguments of LilyPond \consists commands.

>>> block.consists_commands
['Horizontal_bracket_engraver']

Returns list.

ContextBlock.items

Gets items in context block.

>>> block.items
['\\accidentalStyle dodecaphonic']

Returns list.

ContextBlock.name

Gets and sets argument of LilyPond \name command.

>>> block.name
'FluteStaff'

Returns string or none.

ContextBlock.remove_commands

Gets arguments of LilyPond \remove commands.

>>> block.remove_commands
['Forbid_line_break_engraver']

Returns list.

ContextBlock.source_context_name

Gets and sets source context name.

>>> block.source_context_name
'Staff'

Returns string or none.

ContextBlock.type_

Gets and sets argument of LilyPond \type command.

>>> block.type_
'Engraver_group'

Returns string or none.

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 = abjad.Block(name='score')
>>> score = abjad.Score(name='Red Example Score')
>>> block.items.append(score)
>>> block['Red Example Score']
Score(is_simultaneous=True, name='Red Example Score')

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.

(Block).__setattr__(name, value)

Sets block name to value.

Returns none.