o
    ?8¾\€  ã                   @   sl   d Z ddlmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZdd„ Z	dS )zkTools for working with `collations`_.

.. _collations: http://userguide.icu-project.org/collation/concepts
é    )Úcommonc                   @   s,   e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZdS )ÚCollationStrengthzd
    An enum that defines values for `strength` on a
    :class:`~pymongo.collation.Collation`.
    é   é   é   é   é   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚPRIMARYÚ	SECONDARYÚTERTIARYÚ
QUATERNARYÚ	IDENTICAL© r   r   úC/var/www/html/env/lib/python3.10/site-packages/pymongo/collation.pyr      s    r   c                   @   ó   e Zd ZdZdZ	 dZdS )ÚCollationAlternateze
    An enum that defines values for `alternate` on a
    :class:`~pymongo.collation.Collation`.
    znon-ignorableÚshiftedN)r	   r
   r   r   ÚNON_IGNORABLEÚSHIFTEDr   r   r   r   r   -   ó    r   c                   @   r   )ÚCollationMaxVariablezh
    An enum that defines values for `max_variable` on a
    :class:`~pymongo.collation.Collation`.
    ÚpunctÚspaceN)r	   r
   r   r   ÚPUNCTÚSPACEr   r   r   r   r   @   r   r   c                   @   s    e Zd ZdZdZ	 dZ	 dZdS )ÚCollationCaseFirstzf
    An enum that defines values for `case_first` on a
    :class:`~pymongo.collation.Collation`.
    ÚupperÚlowerÚoffN)r	   r
   r   r   ÚUPPERÚLOWERÚOFFr   r   r   r   r   M   s    r   c                   @   sR   e Zd ZdZdZ								ddd„Zedd„ ƒZdd	„ Zd
d„ Z	dd„ Z
dS )Ú	Collationa{
  Collation

    :Parameters:
      - `locale`: (string) The locale of the collation. This should be a string
        that identifies an `ICU locale ID` exactly. For example, ``en_US`` is
        valid, but ``en_us`` and ``en-US`` are not. Consult the MongoDB
        documentation for a list of supported locales.
      - `caseLevel`: (optional) If ``True``, turn on case sensitivity if
        `strength` is 1 or 2 (case sensitivity is implied if `strength` is
        greater than 2). Defaults to ``False``.
      - `caseFirst`: (optional) Specify that either uppercase or lowercase
        characters take precedence. Must be one of the following values:

          * :data:`~CollationCaseFirst.UPPER`
          * :data:`~CollationCaseFirst.LOWER`
          * :data:`~CollationCaseFirst.OFF` (the default)

      - `strength`: (optional) Specify the comparison strength. This is also
        known as the ICU comparison level. This must be one of the following
        values:

          * :data:`~CollationStrength.PRIMARY`
          * :data:`~CollationStrength.SECONDARY`
          * :data:`~CollationStrength.TERTIARY` (the default)
          * :data:`~CollationStrength.QUATERNARY`
          * :data:`~CollationStrength.IDENTICAL`

        Each successive level builds upon the previous. For example, a
        `strength` of :data:`~CollationStrength.SECONDARY` differentiates
        characters based both on the unadorned base character and its accents.

      - `numericOrdering`: (optional) If ``True``, order numbers numerically
        instead of in collation order (defaults to ``False``).
      - `alternate`: (optional) Specify whether spaces and punctuation are
        considered base characters. This must be one of the following values:

          * :data:`~CollationAlternate.NON_IGNORABLE` (the default)
          * :data:`~CollationAlternate.SHIFTED`

      - `maxVariable`: (optional) When `alternate` is
        :data:`~CollationAlternate.SHIFTED`, this option specifies what
        characters may be ignored. This must be one of the following values:

          * :data:`~CollationMaxVariable.PUNCT` (the default)
          * :data:`~CollationMaxVariable.SPACE`

      - `normalization`: (optional) If ``True``, normalizes text into Unicode
        NFD. Defaults to ``False``.
      - `backwards`: (optional) If ``True``, accents on characters are
        considered from the back of the word to the front, as it is done in some
        French dictionary ordering traditions. Defaults to ``False``.
      - `kwargs`: (optional) Keyword arguments supplying any additional options
        to be sent with this Collation object.

    .. versionadded: 3.4

    )Ú
__documentNc
                 K   sö   t  d|¡}d|i| _|d urt  d|¡| jd< |d ur%t  d|¡| jd< |d ur2t  d|¡| jd< |d ur?t  d|¡| jd< |d urLt  d|¡| jd< |d urYt  d|¡| jd< |d urft  d|¡| jd< |	d urst  d	|	¡| jd	< | j |
¡ d S )
NÚlocaleÚ	caseLevelÚ	caseFirstÚstrengthÚnumericOrderingÚ	alternateÚmaxVariableÚnormalizationÚ	backwards)r   Úvalidate_stringÚ_Collation__documentÚvalidate_booleanÚvalidate_integerÚupdate)Úselfr(   r)   r*   r+   r,   r-   r.   r/   r0   Úkwargsr   r   r   Ú__init__š   sF   


ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿzCollation.__init__c                 C   s
   | j  ¡ S )zÏThe document representation of this collation.

        .. note::
          :class:`Collation` is immutable. Mutating the value of
          :attr:`document` does not mutate this :class:`Collation`.
        )r2   Úcopy©r6   r   r   r   ÚdocumentÀ   s   
zCollation.documentc                    s$   | j ‰ dd ‡ fdd„ˆ D ƒ¡f S )NzCollation(%s)z, c                 3   s    � | ]}d |ˆ | f V  qdS )z%s=%rNr   )Ú.0Úkey©r;   r   r   Ú	<genexpr>Í   s   € z%Collation.__repr__.<locals>.<genexpr>)r;   Újoinr:   r   r>   r   Ú__repr__Ê   s   ÿzCollation.__repr__c                 C   s   t |tƒr| j|jkS tS ©N)Ú
isinstancer&   r;   ÚNotImplemented©r6   Úotherr   r   r   Ú__eq__Ï   s   
zCollation.__eq__c                 C   s
   | |k S rB   r   rE   r   r   r   Ú__ne__Ô   s   
zCollation.__ne__)NNNNNNNN)r	   r
   r   r   Ú	__slots__r8   Úpropertyr;   rA   rG   rH   r   r   r   r   r&   ]   s"    :
ø&
	r&   c                 C   s2   | d u rd S t | tƒr| jS t | tƒr| S tdƒ‚)NzFcollation must be a dict, an instance of collation.Collation, or None.)rC   r&   r;   ÚdictÚ	TypeError)Úvaluer   r   r   Úvalidate_collation_or_noneØ   s   

ÿrN   N)
r   Úpymongor   Úobjectr   r   r   r   r&   rN   r   r   r   r   Ú<module>   s   {