Line

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.segments" { graph [label="abjad.segments"]; node [color=1]; "abjad.segments.Line.Line" [URL="../api/abjad/segments/Line.html#abjad.segments.Line.Line", color=black, fontcolor=white, label=Line, target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/segments/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.segments.Line.Line"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.segments.Line.Line(string='')

Line in a LilyPond file.

>>> string = '    %@%  \with-color %! MEASURE_NUMBER_MARKUP:SM31'
>>> abjad.Line(string)
Line(string='    %@%  \\with-color %! MEASURE_NUMBER_MARKUP:SM31')

Attributes Summary

__str__ Gets string representation of line.
get_tags Gets tags.
is_active Is true when line is active.
is_deactivated Is true when line is deactivated.
match Is true when predicate matches tags.
string Gets string.

Special methods

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Gets string representation of line.

>>> string = '    %@%  \with-color %! MEASURE_NUMBER_MARKUP:SM31'
>>> str(abjad.Line(string))
'    %@%  \\with-color %! MEASURE_NUMBER_MARKUP:SM31'

Returns string.


Methods

get_tags()

Gets tags.

>>> string = '    %@%  \with-color %! MEASURE_NUMBER_MARKUP:SM31'
>>> abjad.Line(string).get_tags()
['MEASURE_NUMBER_MARKUP', 'SM31']

Returns list of zero or more strings.

is_active()

Is true when line is active.

>>> string = '              \\clef "treble" %! EXPLICT_CLEF'
>>> abjad.Line(string).is_active()
True
>>> string = '          %@% \\clef "treble" %! EXPLICT_CLEF'
>>> abjad.Line(string).is_active()
False
>>> string = '          %%% \\clef "treble" %! EXPLICT_CLEF'
>>> abjad.Line(string).is_active()
False

Returns true or false.

is_deactivated()

Is true when line is deactivated.

>>> string = '              \\clef "treble" %! EXPLICT_CLEF'
>>> abjad.Line(string).is_deactivated()
False
>>> string = '          %@% \\clef "treble" %! EXPLICT_CLEF'
>>> abjad.Line(string).is_deactivated()
True
>>> string = '          %%% \\clef "treble" %! EXPLICT_CLEF'
>>> abjad.Line(string).is_deactivated()
True

Returns true or false.

match(predicate)

Is true when predicate matches tags.

>>> string = '    %@%  \with-color %! MEASURE_NUMBER_MARKUP:SM31'
>>> line = abjad.Line(string)

Strings:

>>> line.match('MEASURE_NUMBER_MARKUP')
True
>>> line.match('SM31')
True
>>> line.match(['MEASURE_NUMBER_MARKUP', 'SM31'])
False
>>> line.match('%@%')
False
>>> line.match('with-color')
False
>>> line.match('%!')
False

Lambdas:

>>> line.match(lambda x: any(_ for _ in x if _.startswith('M')))
True
>>> line.match(lambda x: any(_ for _ in x if _.startswith('S')))
True
>>> line.match(lambda x: any(_ for _ in x if _[0] in 'SM'))
True

Functions:

>>> def predicate(tags):
...     if 'SM31' in tags and 'MEASURE_NUMBER_MARKUP' in tags:
...         return True
...     else:
...         return False
>>> line.match(predicate)
True
>>> def predicate(tags):
...     if 'SM31' in tags and 'MEASURE_NUMBER_MARKUP' not in tags:
...         return True
...     else:
...         return False
>>> line.match(predicate)
False

Returns true or false.


Read-only properties

string

Gets string.

>>> string = '    %@%  \with-color %! MEASURE_NUMBER_MARKUP:SM31'
>>> abjad.Line(string).string
'    %@%  \\with-color %! MEASURE_NUMBER_MARKUP:SM31'

Returns string.