abjad.tweaks

abjad.tweaks.bundle(indicator, *tweaks[, ...])

Bundles indicator with tweaks.

abjad.tweaks.tweak(indicator, *tweaks[, ...])

Appends tweaks to indicator.

abjad.tweaks.Bundle(indicator[, tweaks, comment])

Bundled indicator.

abjad.tweaks.Tweak(string[, i, tag])

Tweak.

abjad.tweaks.bundle(indicator: Any, *tweaks: str | Tweak, comment: str | None = None, overwrite: bool = False, tag: Tag | None = None) Bundle[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/Repositories/Projects/abjad/source/abjad/tweaks.py", line 323, in bundle
    raise Exception(message)
Exception: duplicate 'color' attribute:
Tweak(string='- \\tweak color #blue', i=None, tag=None)
Tweak(string='- \\tweak color #red', i=None, 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', i=None, 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/Repositories/Projects/abjad/source/abjad/tweaks.py", line 337, in bundle
    raise Exception(message)
Exception: duplicate 'color' attribute:
OLD: Tweak(string='- \\tweak color #blue', i=None, tag=None)
NEW: Tweak(string='- \\tweak color #red', i=None, 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', i=None, tag=None)
abjad.tweaks.tweak(indicator: Any, *tweaks: str | Tweak, overwrite: bool = False, tag: Tag | None = None) None[source]

Appends tweaks to indicator.

class abjad.tweaks.Bundle(indicator: Any, tweaks: tuple[Tweak, ...] = (), comment: str | None = None)[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 6, in __init__
  File "/Users/trevor/Repositories/Projects/abjad/source/abjad/tweaks.py", line 106, in __post_init__
    raise Exception(f"duplicate {attribute!r} attribute.")
Exception: duplicate 'color' attribute.

get_attribute(attribute)

Gets tweak with attribute.

remove(tweak)

Removes tweak from bundle and returns new bundle.

get_attribute(attribute: str) Tweak | None[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', i=None, tag=None)
>>> bundle.get_attribute("style") is None
True
remove(tweak: Tweak) Bundle[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=(), comment=None)
>>> bundle_3 = abjad.bundle(bundle_2, r"- \tweak color #blue")
>>> bundle_3.tweaks
(Tweak(string='- \\tweak color #blue', i=None, tag=None),)
class abjad.tweaks.Tweak(string: str, i: int | None = None, tag: Tag | None = None)[source]

Tweak.

attribute()

Gets tweak attribute.

is_post_event()

Is true when tweak is post-event.

value()

Gets tweak value.

attribute() str[source]

Gets tweak attribute.

is_post_event() bool[source]

Is true when tweak is post-event.

value() str[source]

Gets tweak value.