U
    d                     @   s   d Z ddlmZmZmZmZmZ ddlmZ G dd dZ	G dd dZ
G dd	 d	ZG d
d dZG dd dZeeeeef ef  eeeef  dddZdS )zpTools for working with `collations`_.

.. _collations: https://www.mongodb.com/docs/manual/reference/collation/
    )AnyDictMappingOptionalUnion)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__ZPRIMARYZ	SECONDARYZTERTIARYZ
QUATERNARYZ	IDENTICAL r   r   5/tmp/pip-unpacked-wheel-oblwsawz/pymongo/collation.pyr      s   r   c                   @   s   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-ignorableZshiftedN)r   r   r   r   ZNON_IGNORABLEZSHIFTEDr   r   r   r   r   .   s   r   c                   @   s   e Zd ZdZdZdZdS )CollationMaxVariablezh
    An enum that defines values for `max_variable` on a
    :class:`~pymongo.collation.Collation`.
    punctspaceN)r   r   r   r   ZPUNCTSPACEr   r   r   r   r   A   s   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   ZUPPERZLOWERZOFFr   r   r   r   r   N   s
   r   c                   @   s   e Zd ZdZdZdeee ee ee ee ee ee ee ee e	ddddZ
eeee	f ddd	Zedd
dZe	edddZe	ed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

    )Z
__documentN)locale	caseLevel	caseFirststrengthnumericOrdering	alternatemaxVariablenormalization	backwardskwargsreturnc
                 K   s   t d|}d|i| _|d k	r0t d|| jd< |d k	rJt d|| jd< |d k	rdt d|| jd< |d k	r~t d|| jd< |d k	rt d|| jd< |d k	rt d|| jd< |d k	rt d|| jd< |	d k	rt d	|	| jd	< | j|
 d S )
Nr   r   r    r!   r"   r#   r$   r%   r&   )r   Zvalidate_string_Collation__documentZvalidate_booleanZvalidate_integerupdate)selfr   r   r    r!   r"   r#   r$   r%   r&   r'   r   r   r   __init__   s2    
 
 
zCollation.__init__)r(   c                 C   s
   | j  S )zThe document representation of this collation.

        .. note::
          :class:`Collation` is immutable. Mutating the value of
          :attr:`document` does not mutate this :class:`Collation`.
        )r)   copyr+   r   r   r   document   s    zCollation.documentc                    s$   | j  dd fdd D S )NzCollation({})z, c                 3   s    | ]}| d  | V  qdS )=Nr   ).0keyr/   r   r   	<genexpr>   s     z%Collation.__repr__.<locals>.<genexpr>)r/   formatjoinr.   r   r3   r   __repr__   s    zCollation.__repr__)otherr(   c                 C   s   t |tr| j|jkS tS N)
isinstancer   r/   NotImplementedr+   r8   r   r   r   __eq__   s    
zCollation.__eq__c                 C   s
   | |k S r9   r   r<   r   r   r   __ne__   s    zCollation.__ne__)NNNNNNNN)r   r   r   r   	__slots__strr   boolintr   r,   propertyr   r/   r7   r=   r>   r   r   r   r   r   ^   s8   :        %	r   )valuer(   c                 C   s6   | d krd S t | tr| jS t | tr*| S tdd S )NzFcollation must be a dict, an instance of collation.Collation, or None.)r:   r   r/   dict	TypeError)rD   r   r   r   validate_collation_or_none   s    

rG   N)r   typingr   r   r   r   r   Zpymongor   r   r   r   r   r   r@   rG   r   r   r   r   <module>   s   z