abjad.wrapper

abjad.wrapper.Wrapper([annotation, ...])

Wrapper.

class abjad.wrapper.Wrapper(annotation: str | Enum | None = None, check_duplicate_indicator: bool = False, component: Component | None = None, context: str | None = None, deactivate: bool = False, direction: Vertical | None = None, indicator: Any = None, synthetic_offset: Offset | None = None, tag: Tag = Tag(string=''))[source]

Wrapper.

Attaches articulation to note and makes wrapper:

>>> component = abjad.Note("c'4")
>>> articulation = abjad.Articulation("accent")
>>> abjad.attach(articulation, component, direction=abjad.UP)
>>> abjad.get.wrapper(component)
Wrapper(annotation=None, context=None, deactivate=False, direction=<Vertical.UP: 1>, indicator=Articulation(name='accent'), synthetic_offset=None, tag=Tag(string=''))

Duplicate indicator warnings take two forms.

>>> voice_1 = abjad.Voice("c''4 d'' e'' f''", name="VoiceI")
>>> voice_2 = abjad.Voice("c'4 d' e' f'", name="VoiceII")
>>> staff = abjad.Staff([voice_1, voice_2], simultaneous=True)
>>> abjad.attach(abjad.Clef("alto"), voice_2[0])
>>> abjad.show(staff)  

First form when attempting to attach a contexted indicator to a leaf that already carries a contexted indicator of the same type:

>>> # abjad.attach(abjad.Clef("treble"), voice_2[0])

Second form when attempting to attach a contexted indicator to a leaf governed by some other component carrying a contexted indicator of the same type.

>>> # abjad.attach(abjad.Clef("treble"), voice_1[0])

annotation

Gets wrapper annotation.

bundled()

Is true when indicator is bundled.

component

Gets start component.

context

Gets context (name).

deactivate

Is true when wrapper deactivates tag.

direction

Gets direction of indicator.

get_item()

Gets indicator or bundled indicator.

indicator

Gets indicator.

leaked_start_offset

Gets start offset and checks to see whether indicator leaks to the right.

site_adjusted_start_offset

Gets site-adjusted start offset.

start_offset

Gets start offset.

synthetic_offset

Gets synthetic offset.

tag

Gets and sets tag.

unbundle_indicator()

Unbundles indicator.

annotation

Gets wrapper annotation.

>>> note = abjad.Note("c'4")
>>> articulation = abjad.Articulation("accent")
>>> abjad.attach(articulation, note, direction=abjad.UP)
>>> wrapper = abjad.get.wrapper(note)
>>> wrapper.annotation is None
True
>>> note = abjad.Note("c'4")
>>> articulation = abjad.Articulation("accent")
>>> abjad.annotate(note, "foo", articulation)
>>> abjad.get.annotation(note, "foo")
Articulation(name='accent')
bundled()[source]

Is true when indicator is bundled.

component

Gets start component.

context

Gets context (name).

deactivate

Is true when wrapper deactivates tag.

direction

Gets direction of indicator.

get_item()[source]

Gets indicator or bundled indicator.

indicator

Gets indicator.

leaked_start_offset

Gets start offset and checks to see whether indicator leaks to the right.

This is either the wrapper’s synthetic offset (if set); or the START offset of the wrapper’s component (if indicator DOES NOT leak); or else the STOP offset of the wrapper’s component (if indicator DOES leak).

Start- and stop-text-spans attach to the same leaf. But stop-text-span leaks to the right:

>>> voice = abjad.Voice("c'2 d'2")
>>> start_text_span = abjad.StartTextSpan()
>>> abjad.attach(start_text_span, voice[0])
>>> stop_text_span = abjad.StopTextSpan(leak=True)
>>> abjad.attach(stop_text_span, voice[0])
>>> abjad.show(voice)  
>>> string = abjad.lilypond(voice)
>>> print(string)
\new Voice
{
    c'2
    \startTextSpan
    <>
    \stopTextSpan
    d'2
}

Start offset and leaked start offset are the same for start-text-span:

>>> wrapper = abjad.get.wrapper(voice[0], abjad.StartTextSpan)
>>> wrapper.start_offset, wrapper.leaked_start_offset
(Offset((0, 1)), Offset((0, 1)))

Start offset and leaked start offset differ for stop-text-span:

>>> wrapper = abjad.get.wrapper(voice[0], abjad.StopTextSpan)
>>> wrapper.start_offset, wrapper.leaked_start_offset
(Offset((0, 1)), Offset((1, 2)))
site_adjusted_start_offset

Gets site-adjusted start offset.

Indicators with site equal to absolute_after, after or closing give a site-adjusted start offset equal to the stop offset of the wrapper’s component.

Indicators with any other site give a site-adjusted start offset equal to the start offset of the wrapper’s component. This is the usual case, and means that site-adjusted start offset equals vanilla start offset.

But if synthetic_offset is set then synthetic_offset is returned directly without examining the format site at all.

>>> staff = abjad.Staff("c'4")
>>> abjad.attach(abjad.Ottava(-1, site="before"), staff[0])
>>> abjad.attach(abjad.Ottava(0, site="after"), staff[0])
>>> for wrapper in abjad.get.wrappers(staff[0], abjad.Ottava):
...     wrapper.indicator, wrapper.site_adjusted_start_offset
... 
(Ottava(n=-1, site='before'), Offset((0, 1)))
(Ottava(n=0, site='after'), Offset((1, 4)))
start_offset

Gets start offset.

This is either the wrapper’s synthetic offset or the start offset of the wrapper’s component.

synthetic_offset

Gets synthetic offset.

tag

Gets and sets tag.

unbundle_indicator()[source]

Unbundles indicator.