Tag

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.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.Tag.Tag" [URL="../api/abjad/system/Tag.html#abjad.system.Tag.Tag", color=black, fontcolor=white, label=Tag, target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.Tag.Tag"; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.system.Tag.Tag(string=None)

Tag.

>>> abjad.Tag('YELLOW')
Tag('YELLOW')
>>> abjad.Tag('YELLOW:RED')
Tag('YELLOW:RED')

Removes duplicate words at initialization:

>>> abjad.Tag('YELLOW:RED:RED')
Tag('YELLOW:RED')

Initializes from other tag:

>>> abjad.Tag(abjad.Tag('YELLOW'))
Tag('YELLOW')

Raises exception on multiple only-edition tags:

>>> abjad.Tag('+SEGMENT:+PARTS')
Traceback (most recent call last):
    ...
Exception: at most one only-edition tag: ['+SEGMENT', '+PARTS'].

Raises exception on mixed only-edition / not-edition tags:

>>> abjad.Tag('+SEGMENT:-PARTS')
Traceback (most recent call last):
    ...
Exception: only-edition and not-edition forbidden in same tag:

['+SEGMENT'] / ['-PARTS']

Attributes Summary

__bool__ Is true when tag has words.
__contains__ Is true when argument is word in tag.
__eq__ Is true when argument is tag with same string representation.
__hash__ Hashes tag.
__iter__ Iterates words in tag.
__str__ Changes tag to string.
append Appends word to tag.
editions Gets edition tags in tag.
extend Extends tag with words.
from_words Makes tag from words.
has_persistence_tag Is true when tag has persistence tag.
invert_edition_tags Inverts edition tags in tag.
not_editions Gets not-edition tags in tag.
only_edition Gets only-edition tag in tag.
prepend Prepends word to tag.
string Gets string.
words Gets words.

Special methods

__bool__()

Is true when tag has words.

>>> bool(abjad.Tag())
False
>>> bool(abjad.Tag('+PARTS'))
True
__contains__(argument)

Is true when argument is word in tag.

>>> tag = abjad.Tag('-PARTS')
>>> tag = tag.append(abjad.tags.DEFAULT_CLEF)
>>> 'PARTS' in tag
False
>>> '-PARTS' in tag
True
>>> abjad.tags.DEFAULT_CLEF in tag
True
Return type:bool
__eq__(argument)

Is true when argument is tag with same string representation.

>>> tag_1 = abjad.Tag()
>>> tag_2 = abjad.Tag()
>>> tag_3 = abjad.Tag('+PARTS')
>>> tag_1 == tag_1
True
>>> tag_1 == tag_2
True
>>> tag_1 == tag_3
False
>>> tag_2 == tag_1
True
>>> tag_2 == tag_2
True
>>> tag_2 == tag_3
False
>>> tag_3 == tag_1
False
>>> tag_3 == tag_2
False
>>> tag_3 == tag_3
True
(AbjadObject).__format__(format_specification='')

Formats Abjad object.

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

Returns string.

__hash__()

Hashes tag.

__iter__()

Iterates words in tag.

>>> tag = abjad.Tag('-PARTS:-SCORE:DEFAULT_CLEF')
>>> for word  in tag:
...     word
...
'-PARTS'
'-SCORE'
'DEFAULT_CLEF'
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Changes tag to string.

>>> str(abjad.Tag())
''
>>> str(abjad.Tag('-PARTS:-SCORE:DEFAULT_CLEF'))
'-PARTS:-SCORE:DEFAULT_CLEF'

Methods

append(word)

Appends word to tag.

>>> abjad.Tag('-PARTS').append(abjad.tags.DEFAULT_CLEF)
Tag('-PARTS:DEFAULT_CLEF')
Return type:Tag
editions()

Gets edition tags in tag.

>>> abjad.Tag('FOO').editions()
[]
>>> abjad.Tag('+SEGMENT').only_edition()
Tag('+SEGMENT')
>>> abjad.Tag('+SEGMENT:FOO').only_edition()
Tag('+SEGMENT')
>>> abjad.Tag('-SEGMENT').editions()
[Tag('-SEGMENT')]
>>> abjad.Tag('-SEGMENT:FOO').editions()
[Tag('-SEGMENT')]
>>> abjad.Tag('-SEGMENT:-PARTS').editions()
[Tag('-SEGMENT'), Tag('-PARTS')]
Return type:List[Tag]
extend(words)

Extends tag with words.

>>> tag = abjad.Tag('-PARTS')
>>> tag.extend(['-SCORE', abjad.tags.DEFAULT_CLEF])
Tag('-PARTS:-SCORE:DEFAULT_CLEF')
Return type:Tag
has_persistence_tag()

Is true when tag has persistence tag.

>>> abjad.Tag('FOO').has_persistence_tag()
False
>>> abjad.Tag('FOO:DEFAULT_CLEF').has_persistence_tag()
True
>>> abjad.Tag('DEFAULT_CLEF').has_persistence_tag()
True
Return type:bool
invert_edition_tags()

Inverts edition tags in tag.

>>> abjad.Tag('FOO').invert_edition_tags()
Tag('FOO')
>>> abjad.Tag('FOO:-PARTS').invert_edition_tags()
Tag('FOO:+PARTS')
>>> abjad.Tag('FOO:+PARTS').invert_edition_tags()
Tag('FOO:-PARTS')
Return type:Tag
not_editions()

Gets not-edition tags in tag.

>>> abjad.Tag('FOO').not_editions()
[]
>>> abjad.Tag('-SEGMENT').not_editions()
[Tag('-SEGMENT')]
>>> abjad.Tag('-SEGMENT:FOO').not_editions()
[Tag('-SEGMENT')]
>>> abjad.Tag('-SEGMENT:-PARTS').not_editions()
[Tag('-SEGMENT'), Tag('-PARTS')]
Return type:List[Tag]
only_edition()

Gets only-edition tag in tag.

>>> abjad.Tag('FOO').only_edition() is None
True
>>> abjad.Tag('+SEGMENT').only_edition()
Tag('+SEGMENT')
>>> abjad.Tag('+SEGMENT:FOO').only_edition()
Tag('+SEGMENT')
Return type:Optional[Tag]
prepend(word)

Prepends word to tag.

>>> abjad.Tag('-PARTS').prepend(abjad.tags.DEFAULT_CLEF)
Tag('DEFAULT_CLEF:-PARTS')
Return type:Tag

Class & static methods

static from_words(words)

Makes tag from words.

Return type:Tag

Read-only properties

string

Gets string.

>>> abjad.Tag().string is None
True
>>> abjad.Tag('-PARTS:DEFAULT_CLEF').string
'-PARTS:DEFAULT_CLEF'
Return type:Optional[str]
words

Gets words.

>>> abjad.Tag('-PARTS:DEFAULT_CLEF').words
['-PARTS', 'DEFAULT_CLEF']
Return type:List[str]