
    3j                     ^   d dl mZ d dlmZmZmZ d dlZ G d de      Z G d de      Z G d d	ee
      Z	 G d de      Z
 G d deee
      Z G d de      Z G d de      Z G d de
      Z G d de      Z G d de      Z G d de      Zedk(  rd dlZ ej*                          yy)    )annotations)EnumEnumTypeIntEnumNc                       e Zd Z fdZ xZS )StrEnumMetac                    t        |t              r|| j                  j                         v ryy	 t        |   |      S # t        $ r Y yw xY wNTF)
isinstancestr__members__valuessuper__contains__	TypeError)clsitem	__class__s     A/DATA/.local/lib/python3.12/site-packages/music21/common/enums.pyr   zStrEnumMeta.__contains__   sO    dC s--//	7'-- 		s   A   	AA)__name__
__module____qualname__r   __classcell__r   s   @r   r   r      s    	 	    r   c                      e Zd ZdZd Zy)ContainsMetaz
    This is a backport of the Python 3.12 `EnumType` class's contains method.

    This will be removed when Python 3.12 is the minimum version for music21.
    c                4    	  | |       y# t         $ r Y yw xY wr
   )
ValueError)r   r   s     r   r   zContainsMeta.__contains__$   s#    	I 		s    	N)r   r   r   __doc__r    r   r   r   r      s    
r   r   c                  2     e Zd ZdZ fdZed        Z xZS )ContainsEnumzL
    An IntEnum that allows "in" checks against the values of the enum.
    c                P    t         |          }t        j                  dd |      S )Nz(\d+)c                >    dt        | j                  d            dS )N0x   X)intgroup)ms    r   <lambda>z'ContainsEnum.__repr__.<locals>.<lambda>3   s    Bs1771:q.A*Br   )r   __repr__resub)selfvalr   s     r   r-   zContainsEnum.__repr__1   s$    g vvh BCHHr   c                    || j                   v S )N)_value2member_map_)r   r1   s     r   hasValuezContainsEnum.hasValue5   s    c,,,,r   )r   r   r   r    r-   classmethodr4   r   r   s   @r   r#   r#   -   s"    I - -r   r#   )	metaclassc                  >     e Zd ZdZed        Z fdZd Zd Z xZ	S )BooleanEnuma7  
    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                h    t        | t              r"t        |       dk(  rt        | d   t              ryy)N   r   TF)r   tuplelenbool)vs    r   is_bool_tuplezBooleanEnum.is_bool_tuplec   s)    aCFaKJqtT4Jr   c                    t        || j                        rt        |   |      S | j                  }||k(  ry| j                  |      r|d   |u ry|d   |k(  S y)NTr   r'   F)r   r   r   __eq__valuer?   )r0   otherr>   r   s      r   rA   zBooleanEnum.__eq__j   s`    eT^^,7>%((JJ:"tu}Q45= r   c                p    | j                   }| j                  |      r|d   S t        | j                         S )Nr   )rB   r?   r=   )r0   r>   s     r   __bool__zBooleanEnum.__bool__v   s1    JJa Q4KDJJr   c                P    d| j                   j                   d| j                   dS N<.>r   r   namer0   s    r   r-   zBooleanEnum.__repr__|   &    4>>**+1TYYKq99r   )
r   r   r   r    staticmethodr?   rA   rE   r-   r   r   s   @r   r8   r8   :   s,    'P  
 :r   r8   c                      e Zd ZdZd Zd Zy)StrEnuma  
    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    d| j                   j                   d| j                   dS rG   rK   rM   s    r   r-   zStrEnum.__repr__   rN   r   c                ,    t        | j                        S )z
        >>> from music21.common.enums import OffsetSpecial
        >>> str(OffsetSpecial.AT_END)
        'highestTime'
        )r   rB   rM   s    r   __str__zStrEnum.__str__   s     4::r   N)r   r   r   r    r-   rT   r!   r   r   rQ   rQ      s    :r   rQ   c                  <    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZy)ElementSearchz
    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allN)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   rV   rV      sB      FE)L'K,M*L64/O-N
Cr   rV   c                      e Zd ZdZdZdZdZy)OffsetSpeciala  
    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highestOffsetN)r   r   r   r    AT_ENDLOWEST_OFFSETHIGHEST_OFFSETr!   r   r   rn   rn      s    8 F"M$Nr   rn   c                      e Zd ZdZdZdZdZy)GatherSpannersa  
    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completeOnlyN)r   r   r   r    rl   NONECOMPLETE_ONLYr!   r   r   rv   rv      s    6 CD"Mr   rv   c                      e Zd ZdZdZdZdZy)AppendSpannersa;  
    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noneN)r   r   r   r    NORMALRELATED_ONLYrx   r!   r   r   r{   r{      s     F!LDr   r{   c                      e Zd ZdZdZdZy)OrnamentDelaya  
    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defaultDelayN)r   r   r   r    NO_DELAYDEFAULT_DELAYr!   r   r   r   r     s     H"Mr   r   c                      e Zd ZdZdZdZdZy)MeterDivisionzU
    Represents an indication of how to divide a TimeSignature

    * New in v7.
    fastslowr~   N)r   r   r   r    FASTSLOWrx   r!   r   r   r   r     s    
 DDDr   r   __main__)
__future__r   enumr   r   r   r.   r   r   r#   r8   r   rQ   rV   rn   rv   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G r   