tweaks

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.tweaks" { graph [label="abjad.tweaks"]; node [color=1]; "abjad.tweaks.Bundle" [URL="../api/abjad/tweaks.html#abjad.tweaks.Bundle", color=black, fontcolor=white, label=Bundle, target=_top]; "abjad.tweaks.Tweak" [URL="../api/abjad/tweaks.html#abjad.tweaks.Tweak", color=black, fontcolor=white, label=Tweak, target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjad.tweaks.Bundle" [minlen=1]; "builtins.object" -> "abjad.tweaks.Tweak" [minlen=2]; }


Classes

Bundle

Bundled indicator.

Tweak

Tweak.

class abjad.tweaks.Bundle(indicator, tweaks=())[source]

Bundled indicator.

Raises exception on duplicate attributes:

>>> abjad.Bundle(
...     indicator=abjad.Articulation("."),
...     tweaks=(
...         abjad.Tweak(r"- \tweak color #blue"),
...         abjad.Tweak(r"- \tweak color #red"),
...     ),
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 5, in __init__
  File "/Users/trevor/abjad/abjad/tweaks.py", line 89, in __post_init__
    raise Exception(f"duplicate {attribute!r} attribute.")
Exception: duplicate 'color' attribute.

Attributes Summary

__delattr__

Implement delattr(self, name).

__eq__

Return self==value.

__ge__

Return self>=value.

__gt__

Return self>value.

__hash__

Return hash(self).

__le__

Return self<=value.

__lt__

Return self<value.

__post_init__

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

get_attribute

Gets tweak with attribute.

remove

Removes tweak from bundle and returns new bundle.


Special methods

overridden __delattr__(name)

Implement delattr(self, name).

overridden __eq__(other)

Return self==value.

overridden __ge__(other)

Return self>=value.

overridden __gt__(other)

Return self>value.

overridden __hash__()

Return hash(self).

overridden __le__(other)

Return self<=value.

overridden __lt__(other)

Return self<value.

__post_init__()[source]
overridden __repr__()

Return repr(self).

overridden __setattr__(name, value)

Implement setattr(self, name, value).


Methods

get_attribute(attribute)[source]

Gets tweak with attribute.

>>> markup = abjad.Markup(r"\markup Allegro")
>>> bundle = abjad.bundle(
...     markup,
...     r"- \tweak color #red",
...     r"- \tweak font-size 3",
... )
>>> bundle.get_attribute("color")
Tweak(string='- \\tweak color #red', tag=None)
>>> bundle.get_attribute("style") is None
True
Return type:

Optional[Tweak]

remove(tweak)[source]

Removes tweak from bundle and returns new bundle.

>>> markup = abjad.Markup(r"\markup Allegro")
>>> bundle_1 = abjad.bundle(markup, r"- \tweak color #red")
>>> tweak = bundle_1.get_attribute("color")
>>> bundle_2 = bundle_1.remove(tweak)
>>> bundle_2
Bundle(indicator=Markup(string='\\markup Allegro'), tweaks=())
>>> bundle_3 = abjad.bundle(bundle_2, r"- \tweak color #blue")
>>> bundle_3.tweaks
(Tweak(string='- \\tweak color #blue', tag=None),)
Return type:

Bundle

class abjad.tweaks.Tweak(string, tag=None)[source]

Tweak.


Attributes Summary

__delattr__

Implement delattr(self, name).

__eq__

Return self==value.

__ge__

Return self>=value.

__gt__

Return self>value.

__hash__

Return hash(self).

__le__

Return self<=value.

__lt__

Return self<value.

__post_init__

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

attribute

rtype:

str

post_event

rtype:

bool

value

rtype:

str


Special methods

overridden __delattr__(name)

Implement delattr(self, name).

overridden __eq__(other)

Return self==value.

overridden __ge__(other)

Return self>=value.

overridden __gt__(other)

Return self>value.

overridden __hash__()

Return hash(self).

overridden __le__(other)

Return self<=value.

overridden __lt__(other)

Return self<value.

__post_init__()[source]
overridden __repr__()

Return repr(self).

overridden __setattr__(name, value)

Implement setattr(self, name, value).


Methods

attribute()[source]
Return type:

str

post_event()[source]
Return type:

bool

value()[source]
Return type:

str


Functions

bundle

Bundles indicator with tweaks.

tweak

Appends tweaks to indicator.

abjad.tweaks.bundle(indicator, *tweaks, tag=None, overwrite=False)[source]

Bundles indicator with tweaks.

Bundles indicator:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> bundle = abjad.bundle(
...     abjad.Articulation("."),
...     r"- \tweak color #red",
... )
>>> abjad.attach(bundle, staff[0])
>>> abjad.show(staff)  

Bundles existing bundle:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> bundle = abjad.bundle(abjad.Articulation("."), r"- \tweak color #red")
>>> bundle = abjad.bundle(bundle, r"- \tweak font-size 3")
>>> abjad.attach(bundle, staff[0])
>>> abjad.show(staff)  

Raises exception on duplicate attribute:

>>> bundle = abjad.bundle(
...     abjad.Articulation("."),
...     r"- \tweak color #blue",
...     r"- \tweak color #red",
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/trevor/abjad/abjad/tweaks.py", line 302, in bundle
    raise Exception(message)
Exception: duplicate 'color' attribute:
Tweak(string='- \\tweak color #blue', tag=None)
Tweak(string='- \\tweak color #red', tag=None)

Unless overwrite=True:

>>> bundle = abjad.bundle(
...     abjad.Articulation("."),
...     r"- \tweak color #blue",
...     r"- \tweak color #red",
...     overwrite=True,
... )
>>> for _ in bundle.tweaks:
...     _
... 
Tweak(string='- \\tweak color #red', tag=None)

Also raises exception on duplicate attribute:

>>> bundle = abjad.bundle(
...     abjad.Articulation("."),
...     r"- \tweak color #blue",
... )
>>> bundle = abjad.bundle(
...     bundle,
...     r"- \tweak color #red",
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/trevor/abjad/abjad/tweaks.py", line 316, in bundle
    raise Exception(message)
Exception: duplicate 'color' attribute:
OLD: Tweak(string='- \\tweak color #blue', tag=None)
NEW: Tweak(string='- \\tweak color #red', tag=None)

Unless overwrite=True:

>>> bundle = abjad.bundle(
...     abjad.Articulation("."),
...     r"- \tweak color #blue",
... )
>>> bundle = abjad.bundle(
...     bundle,
...     r"- \tweak color #red",
...     overwrite=True,
... )
>>> for _ in bundle.tweaks:
...     _
... 
Tweak(string='- \\tweak color #red', tag=None)
Return type:

Bundle

abjad.tweaks.tweak(indicator, *tweaks, overwrite=False, tag=None)[source]

Appends tweaks to indicator.

Return type:

None