
    rh                     T   S SK Jr  S SKJrJrJr  S SKr " S S\5      r " S S\5      r " S S	\\S
9r	 " S S\5      r
 " S S\\\S
9r " S S\5      r " S S\5      r " S S\
5      r " S S\5      r " S S\5      r " S S\5      r\S:X  a  S SKr\R*                  " 5         gg)    )annotations)EnumEnumMetaIntEnumNc                  (   ^  \ rS rSrU 4S jrSrU =r$ )StrEnumMeta   c                   > [        U[        5      (       a  XR                  R                  5       ;   a  gg [        TU ]  U5      $ ! [         a     gf = fNTF)
isinstancestr__members__valuessuper__contains__	TypeError)clsitem	__class__s     N/home/james-whalen/.local/lib/python3.13/site-packages/music21/common/enums.pyr   StrEnumMeta.__contains__   sP    dC  --//	7'-- 		s   A 
AA )__name__
__module____qualname____firstlineno__r   __static_attributes____classcell__r   s   @r   r   r      s    	 	    r   c                      \ rS rSrSrS rSrg)ContainsMeta!   zK
This is a backport of the Python 3.12 `EnumType` class's contains method.
c                6     U " U5        g! [          a     gf = fr   )
ValueError)r   r   s     r   r   ContainsMeta.__contains__%   s#    	I 		s    
r   N)r   r   r   r   __doc__r   r   r   r    r   r"   r"   !   s    r    r"   c                  <   ^  \ rS rSrSrU 4S jr\S 5       rSrU =r	$ )ContainsEnum.   zD
An IntEnum that allows "in" checks against the values of the enum.
c                R   > [         TU ]  5       n[        R                  " SS U5      $ )Nz(\d+)c                >    S[        U R                  S5      5      S 3$ )N0x   X)intgroup)ms    r   <lambda>'ContainsEnum.__repr__.<locals>.<lambda>4   s    Bs1771:q.A*Br    )r   __repr__resub)selfvalr   s     r   r5   ContainsEnum.__repr__2   s$    g vvh BCHHr    c                    XR                   ;   $ )N)_value2member_map_)r   r9   s     r   hasValueContainsEnum.hasValue6   s    ,,,,r    r   )
r   r   r   r   r'   r5   classmethodr=   r   r   r   s   @r   r)   r)   .   s"    I - -r    r)   )	metaclassc                  H   ^  \ rS rSrSr\S 5       rU 4S jrS rS r	Sr
U =r$ )BooleanEnum;   a  
An enum that replaces a boolean, except the "is" part, and
allows specifying multiple values that can specify whether they
equate to True or False.

Useful for taking an element that was previously True/False and
replacing it in a backwards-compatible way with an Enum.

>>> from music21.common.enums import BooleanEnum
>>> class Maybe(BooleanEnum):
...    YES = True
...    NO = False
...    MAYBE = 0.5
...    NOT_A_CHANCE = (False, 'not a chance')
...    DEFINITELY = (True, 'of course!')
>>> bool(Maybe.YES)
True
>>> bool(Maybe.NO)
False
>>> bool(Maybe.MAYBE)
True
>>> bool(Maybe.NOT_A_CHANCE)
False
>>> bool(Maybe.DEFINITELY)
True
>>> Maybe.MAYBE == 0.5
True
>>> Maybe.NOT_A_CHANCE == 'not a chance'
True
>>> Maybe.NOT_A_CHANCE == False
True
>>> Maybe.NOT_A_CHANCE == True
False
>>> Maybe.NOT_A_CHANCE == 'not any chance'
False
>>> Maybe.DEFINITELY == 'of course!'
True
>>> Maybe.NOT_A_CHANCE == (False, 'not a chance')
True
c                ~    [        U [        5      (       a(  [        U 5      S:X  a  [        U S   [        5      (       a  gg)N   r   TF)r   tuplelenbool)vs    r   is_bool_tupleBooleanEnum.is_bool_tupled   s/    aCFaKJqtT4J4Jr    c                   > [        XR                  5      (       a  [        TU ]  U5      $ U R                  nX!:X  a  gU R                  U5      (       a  US   UL a  gUS   U:H  $ g)NTr   r.   F)r   r   r   __eq__valuerJ   )r8   otherrI   r   s      r   rM   BooleanEnum.__eq__k   sb    e^^,,7>%((JJ:""tu}Q45= r    c                z    U R                   nU R                  U5      (       a  US   $ [        U R                   5      $ )Nr   )rN   rJ   rH   )r8   rI   s     r   __bool__BooleanEnum.__bool__w   s4    JJa  Q4KDJJr    c                P    SU R                   R                   SU R                   S3$ N<.>r   r   namer8   s    r   r5   BooleanEnum.__repr__}   &    4>>**+1TYYKq99r    r   )r   r   r   r   r'   staticmethodrJ   rM   rR   r5   r   r   r   s   @r   rB   rB   ;   s1    'P  
 : :r    rB   c                  $    \ rS rSrSrS rS rSrg)StrEnum   a  
An enumeration where strings can equal the value, and strings
can be found "in" the enum.

See :class:`music21.common.enums.OffsetSpecial` for an
example of how subclassing this would work.

* Note: This class predates the equivalent StrEnum in Python 3.11
  and the changes to Enum `__contains__` in 3.12.  Once
  Python 3.12 is the minimum version of music21, this class
  will no longer be used internally and will eventually become
  deprecated (2027?) and removed (2030?).
c                P    SU R                   R                   SU R                   S3$ rU   rY   r[   s    r   r5   StrEnum.__repr__   r]   r    c                ,    [        U R                  5      $ )z`
>>> from music21.common.enums import OffsetSpecial
>>> str(OffsetSpecial.AT_END)
'highestTime'
)r   rN   r[   s    r   __str__StrEnum.__str__   s     4::r    r   N)r   r   r   r   r'   r5   re   r   r   r    r   r`   r`      s    :r    r`   c                  D    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrg)ElementSearch   z
An enum representing the element search directions that can be provided
to :meth:`~music21.base.Music21Object.getContextByClass`.
getElementBeforegetElementAftergetElementAtOrBeforegetElementAtOrAftergetElementBeforeOffsetgetElementAfterOffsetgetElementAtOrBeforeOffsetgetElementAtOrAfterOffsetgetElementBeforeNotSelfgetElementAfterNotSelfallr   N)r   r   r   r   r'   BEFOREAFTERAT_OR_BEFOREAT_OR_AFTERBEFORE_OFFSETAFTER_OFFSETAT_OR_BEFORE_OFFSETAT_OR_AFTER_OFFSETBEFORE_NOT_SELFAFTER_NOT_SELFALLr   r   r    r   rh   rh      sB      FE)L'K,M*L64/O-N
Cr    rh   c                  $    \ rS rSrSrSrSrSrSrg)OffsetSpecial   ao  
An enum that represents special offsets.

The enum `AT_END` is equal to the string 'highestTime'

>>> from music21.common.enums import OffsetSpecial
>>> OffsetSpecial.AT_END
<OffsetSpecial.AT_END>
>>> 'highestTime' == OffsetSpecial.AT_END
True
>>> 'crazyOffset' in OffsetSpecial
False
>>> 6.0 in OffsetSpecial
False
>>> 'lowestOffset' in OffsetSpecial
True
>>> str(OffsetSpecial.AT_END)
'highestTime'

* New in v7.
* Note -- a previous note said that the 'highestTime' == OffsetSpecial.AT_END
  would be removed in v9 or an upcoming music21 release.  Since then, Python has
  changed direction and in 3.11 added StrEnum to the standard library and in 3.12
  allows for containment checks of strings in StrEnum (such as
  `'lowestOffset' in OffsetSpecial` returning True).  Therefore there is no
  reason for music21 to ever remove this valuable and backwards compatible
  tool.
highestTimelowestOffsethighestOffsetr   N)	r   r   r   r   r'   AT_ENDLOWEST_OFFSETHIGHEST_OFFSETr   r   r    r   r   r      s    8 F"M$Nr    r   c                  $    \ rS rSrSrSrSrSrSrg)GatherSpanners   a5  
An enumeration for how to gather missing spanners

>>> from music21.common.enums import GatherSpanners

Indicates all relevant spanners will be gathered:

>>> GatherSpanners.ALL
<GatherSpanners.ALL>
>>> bool(GatherSpanners.ALL)
True

Indicates no relevant spanners will be gathered:

>>> GatherSpanners.NONE
<GatherSpanners.NONE>
>>> bool(GatherSpanners.NONE)
False

Indicates only spanners where all of their members are in the excerpt
will be gathered:

>>> GatherSpanners.COMPLETE_ONLY
<GatherSpanners.COMPLETE_ONLY>
>>> bool(GatherSpanners.COMPLETE_ONLY)
True
TFcompleteOnlyr   N)	r   r   r   r   r'   r   NONECOMPLETE_ONLYr   r   r    r   r   r      s    6 CD"Mr    r   c                  $    \ rS rSrSrSrSrSrSrg)AppendSpanners   a  
An enumeration for how to append related spanners when appending objects to a written file.

AppendSpanners.NORMAL means append the spanners that start with the object, then append
    the object, then append the spanners that end with the object.
AppendSpanners.RELATED_ONLY means append the spanners that start with the object, then
    append the spanners that end with the object (i.e. do not append the object).
AppendSpanners.NONE means do not append the related spanners at all (i.e. only append
    the object).

* new in v9.
normalrelated_onlynoner   N)	r   r   r   r   r'   NORMALRELATED_ONLYr   r   r   r    r   r   r      s     F!LDr    r   c                       \ rS rSrSrSrSrSrg)OrnamentDelayi  ak  
An enumeration for the delay in an ornament (e.g. a delayed turn).  The delay for an
ornament can be set to one of these values, or to an OffsetQL for a timed delay.

OrnamentDelay.NO_DELAY means there is no delay (this is equivalent to setting delay to 0.0)
OrnamentDelay.DEFAULT_DELAY means the delay is half the duration of the ornamented note.

* new in v9.
noDelaydefaultDelayr   N)r   r   r   r   r'   NO_DELAYDEFAULT_DELAYr   r   r    r   r   r     s     H"Mr    r   c                  $    \ rS rSrSrSrSrSrSrg)MeterDivisioni  zI
Represents an indication of how to divide a TimeSignature

* New in v7.
fastslowr   r   N)	r   r   r   r   r'   FASTSLOWr   r   r   r    r   r   r     s    
 DDDr    r   __main__)
__future__r   enumr   r   r   r6   r   r"   r)   rB   r   r`   rh   r   r   r   r   r   r   music21mainTestr   r    r   <module>r      s    # ( ( 	
( 

8 

-7l 
-C:$ C:Lc4; 4G $%G %D#[ #BW $#G #G  z r    