MarkupList

class markuptools.MarkupList(items=None, item_class=None, keep_sorted=None)

Markup list.

Initializes from strings:

>>> markups = ['Allegro', 'assai']
>>> markup_list = MarkupList(markups)
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> markup_list = expression(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 

Markup list implement the list interface and are mutable.

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_datastructuretools { graph [label=datastructuretools]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" [color=3, group=2, label=TypedCollection, shape=oval, style=bold]; "abjad.tools.datastructuretools.TypedList.TypedList" [color=3, group=2, label=TypedList, shape=box]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" -> "abjad.tools.datastructuretools.TypedList.TypedList"; } subgraph cluster_markuptools { graph [label=markuptools]; "abjad.tools.markuptools.MarkupList.MarkupList" [color=black, fontcolor=white, group=3, label=<<B>MarkupList</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.datastructuretools.TypedCollection.TypedCollection"; "abjad.tools.datastructuretools.TypedList.TypedList" -> "abjad.tools.markuptools.MarkupList.MarkupList"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Attribute summary

append(item) Appends item to markup list.
center_column([direction]) LilyPond \center-column markup command.
column([direction]) LilyPond \column markup command.
combine([direction]) LilyPond \combine markup command.
concat([direction]) LilyPond \concat markup command.
count(item) Counts item in markup list.
extend(items) Extends markup list with items.
index(item) Gets index of item in markup list.
insert(i, item) Inserts item in markup markup list.
item_class Gets markup list item class.
items Gets markup list items.
keep_sorted Is true when markup list keeps markups sorted.
left_column([direction]) LilyPond \left-column markup command.
line([direction]) LilyPond \line markup command.
overlay([direction]) LilyPond \overlay markup command.
pop([i]) Pops item i from markup list.
remove(item) Removes item from markup list.
reverse() Reverses items in typed list.
right_column([direction]) LilyPond \right-column markup command.
sort([cmp, key, reverse]) Sorts items in typed list.
__contains__(item) Is true when markup markup list contains item.
__delitem__(i) Aliases list.__delitem__().
__eq__(argument) Is true when argument is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats markup list.
__getitem__(argument) Gets item or slice identified by argument.
__hash__() Hashes typed collection.
__iadd__(argument) Changes items in argument to items and extends markup list.
__illustrate__() Illustrates markup markup list.
__iter__() Iterates typed collection.
__len__() Gets length of typed collection.
__ne__(argument) Is true when argument is not a typed collection with items equal to this typed collection.
__repr__() Gets interpreter representation of Abjad object.
__reversed__() Aliases list.__reversed__().
__setitem__(i, argument) Sets item i equal to argument.

Read-only properties

MarkupList.item_class

Gets markup list item class.

>>> MarkupList().item_class
<class 'abjad.tools.markuptools.Markup.Markup'>

Returns markup class.

MarkupList.items

Gets markup list items.

Initializes items positionally:

>>> items = ['Allegro', 'assai']
>>> markup_list = MarkupList(items)
>>> for item in markup_list.items:
...     item
...
Markup(contents=['Allegro'])
Markup(contents=['assai'])

Initializes items from keyword:

>>> items = ['Allegro', 'assai']
>>> markup_list = MarkupList(items=items)
>>> for item in markup_list.items:
...     item
...
Markup(contents=['Allegro'])
Markup(contents=['assai'])

Initializes items positionally:

>>> items = ['Allegro', 'assai']
>>> expression = Expression().markup_list()
>>> markup_list = expression(items)
>>> for item in markup_list.items:
...     item
...
Markup(contents=['Allegro'])
Markup(contents=['assai'])

Initializes items from keyword:

>>> items = ['Allegro', 'assai']
>>> expression = Expression().markup_list()
>>> markup_list = expression(items=items)
>>> for item in markup_list.items:
...     item
...
Markup(contents=['Allegro'])
Markup(contents=['assai'])

Returns tuple.

MarkupList.keep_sorted

Is true when markup list keeps markups sorted. Otherwise false.

Keeps markup sorted:

>>> markups = ['Allegro', 'assai']
>>> markup_list = MarkupList(keep_sorted=True)
>>> markup_list.append('assai')
>>> markup_list.append('Allegro')
>>> show(markup_list) 

Does not keep markup sorted:

>>> markups = ['Allegro', 'assai']
>>> markup_list = MarkupList()
>>> markup_list.append('assai')
>>> markup_list.append('Allegro')
>>> show(markup_list) 

Defaults to none.

Set to true, false or none.

Returns true, false or none.

Methods

MarkupList.append(item)

Appends item to markup list.

>>> markup_list = MarkupList(['Allegro'])
>>> markup_list.append('assai')
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> expression = expression.append('assai')
>>> markup_list = expression(['Allegro'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 

Returns none.

MarkupList.center_column(direction=None)

LilyPond \center-column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markups = [city, date]
>>> markup_list = MarkupList(markups)
>>> markup = markup_list.center_column(direction=Up)
>>> f(markup)
^ \markup {
    \center-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.center_column(direction=Up)
>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markups = [city, date]
>>> markup = expression(markups)
>>> f(markup)
^ \markup {
    \center-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

MarkupList.column(direction=None)

LilyPond \column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup_list = MarkupList([city, date])
>>> markup = markup_list.column()
>>> f(markup)
\markup {
    \column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.column()
>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = expression([city, date])
>>> f(markup)
\markup {
    \column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

MarkupList.combine(direction=None)

LilyPond \combine markup command.

>>> markup_one = Markup('Allegro assai')
>>> markup_two = Markup.draw_line(13, 0)
>>> markup_list = [markup_one, markup_two]
>>> markup_list = MarkupList(markup_list)
>>> markup = markup_list.combine(direction=Up)
>>> f(markup)
^ \markup {
    \combine
        "Allegro assai"
        \draw-line
            #'(13 . 0)
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.combine(direction=Up)
>>> markup_1 = Markup('Allegro assai')
>>> markup_2 = Markup.draw_line(13, 0)
>>> markup_list = [markup_1, markup_2]
>>> markup = expression(markup_list)
>>> f(markup)
^ \markup {
    \combine
        "Allegro assai"
        \draw-line
            #'(13 . 0)
    }
>>> show(markup) 

Returns new markup.

MarkupList.concat(direction=None)

LilyPond \concat markup command.

>>> downbow = Markup.musicglyph('scripts.downbow')
>>> hspace = Markup.hspace(1)
>>> upbow = Markup.musicglyph('scripts.upbow')
>>> markups = [downbow, hspace, upbow]
>>> markup_list = MarkupList(markups)
>>> markup = markup_list.concat(direction=Up)
>>> f(markup)
^ \markup {
    \concat
        {
            \musicglyph
                #"scripts.downbow"
            \hspace
                #1
            \musicglyph
                #"scripts.upbow"
        }
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.concat(direction=Up)
>>> downbow = Markup.musicglyph('scripts.downbow')
>>> hspace = Markup.hspace(1)
>>> upbow = Markup.musicglyph('scripts.upbow')
>>> markups = [downbow, hspace, upbow]
>>> markup = expression(markups)
>>> f(markup)
^ \markup {
    \concat
        {
            \musicglyph
                #"scripts.downbow"
            \hspace
                #1
            \musicglyph
                #"scripts.upbow"
        }
    }
>>> show(markup) 

Returns new markup.

MarkupList.count(item)

Counts item in markup list.

>>> markup_list = MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> show(markup_list) 
>>> markup_list.count('Allegro')
1
>>> markup_list.count('assai')
1
>>> markup_list.count('ma non troppo')
0

Returns none.

MarkupList.extend(items)

Extends markup list with items.

>>> markup_list = MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> expression = expression.extend(['assai'])
>>> markup_list = expression(['Allegro'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 

Returns none.

MarkupList.index(item)

Gets index of item in markup list.

>>> markup_list = MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 
>>> markup_list.index('Allegro')
0
>>> markup_list.index('assai')
1

Returns none.

MarkupList.insert(i, item)

Inserts item in markup markup list.

>>> markup_list = MarkupList(['assai'])
>>> markup_list.insert(0, 'Allegro')
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> expression = expression.insert(0, 'Allegro')
>>> markup_list = expression(['assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 

Returns markup class.

MarkupList.left_column(direction=None)

LilyPond \left-column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup_list = MarkupList([city, date])
>>> markup = markup_list.left_column()
>>> f(markup)
\markup {
    \left-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.left_column()
>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = expression([city, date])
>>> f(markup)
\markup {
    \left-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

MarkupList.line(direction=None)

LilyPond \line markup command.

>>> markups = ['Allegro', 'assai']
>>> markup_list = MarkupList(markups)
>>> markup = markup_list.line()
>>> f(markup)
\markup {
    \line
        {
            Allegro
            assai
        }
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.line()
>>> markup = expression(['Allegro', 'assai'])
>>> f(markup)
\markup {
    \line
        {
            Allegro
            assai
        }
    }
>>> show(markup) 

Returns new markup.

MarkupList.overlay(direction=None)

LilyPond \overlay markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup_list = MarkupList([city, date])
>>> markup = markup_list.overlay(direction=Up)
>>> f(markup)
^ \markup {
    \overlay
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.overlay(direction=Up)
>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = expression([city, date])
>>> f(markup)
^ \markup {
    \overlay
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

MarkupList.pop(i=-1)

Pops item i from markup list.

>>> markup_list = MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list.pop()
Markup(contents=['assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> expression = expression.pop()
>>> markup_list = expression(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        ],
    )
>>> show(markup_list) 

Returns none.

MarkupList.remove(item)

Removes item from markup list.

>>> markup_list = MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list.remove('assai')
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> expression = expression.remove('assai')
>>> markup_list = expression(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        ],
    )
>>> show(markup_list) 

Returns none.

(TypedList).reverse()

Reverses items in typed list.

MarkupList.right_column(direction=None)

LilyPond \right-column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup_list = MarkupList([city, date])
>>> markup = markup_list.right_column()
>>> f(markup)
\markup {
    \right-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 
>>> expression = Expression().markup_list()
>>> expression = expression.right_column()
>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = expression([city, date])
>>> f(markup)
\markup {
    \right-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

(TypedList).sort(cmp=None, key=None, reverse=False)

Sorts items in typed list.

Special methods

MarkupList.__contains__(item)

Is true when markup markup list contains item. Otherwise false.

>>> markups = ['Allegro', 'assai']
>>> markup_list = MarkupList(markups)
>>> 'assai' in markup_list
True
>>> expression = Expression().markup_list()
>>> markup_list = expression(['Allegro', 'assai'])
>>> 'assai' in markup_list
True

Returns true or false.

(TypedList).__delitem__(i)

Aliases list.__delitem__().

Returns none.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection. Otherwise false.

Returns true or false.

MarkupList.__format__(format_specification='')

Formats markup list.

Formats markup list:

>>> markups = ['Allegro', 'assai']
>>> markup_list = MarkupList(markups)
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )

Formats markup list expression:

>>> expression = Expression().markup_list()
>>> f(expression)
expressiontools.Expression(
    callbacks=[
        expressiontools.Expression(
            evaluation_template='abjad.markuptools.MarkupList',
            is_initializer=True,
            ),
        ],
    proxy_class=markuptools.MarkupList,
    )

Returns string.

(TypedList).__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

(TypedCollection).__hash__()

Hashes typed collection.

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

Returns integer.

MarkupList.__iadd__(argument)

Changes items in argument to items and extends markup list.

>>> markup_list = MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list += ['ma', 'non', 'troppo']
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        markuptools.Markup(
            contents=['ma'],
            ),
        markuptools.Markup(
            contents=['non'],
            ),
        markuptools.Markup(
            contents=['troppo'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> expression += ['ma', 'non', 'troppo']
>>> markup_list = expression(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        markuptools.Markup(
            contents=['ma'],
            ),
        markuptools.Markup(
            contents=['non'],
            ),
        markuptools.Markup(
            contents=['troppo'],
            ),
        ],
    )
>>> show(markup_list) 

Returns none.

MarkupList.__illustrate__()

Illustrates markup markup list.

>>> markups = ['Allegro', 'assai']
>>> markup_list = MarkupList(markups)
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> markup_list = expression(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['assai'],
            ),
        ],
    )
>>> show(markup_list) 

Returns LilyPond file.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(TypedCollection).__ne__(argument)

Is true when argument is not a typed collection with items equal to this typed collection. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedList).__reversed__()

Aliases list.__reversed__().

Returns generator.

MarkupList.__setitem__(i, argument)

Sets item i equal to argument.

>>> markup_list = MarkupList()
>>> markup_list.extend(['Allegro', 'assai'])
>>> markup_list[-1] = 'non troppo'
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['non troppo'],
            ),
        ],
    )
>>> show(markup_list) 
>>> expression = Expression().markup_list()
>>> expression = expression.__setitem__(-1, 'non troppo')
>>> markup_list = expression(['Allegro', 'assai'])
>>> f(markup_list)
markuptools.MarkupList(
    items=[
        markuptools.Markup(
            contents=['Allegro'],
            ),
        markuptools.Markup(
            contents=['non troppo'],
            ),
        ],
    )
>>> show(markup_list) 

Returns none.