o Sb:@sdZddlmZmZmZmZmZddlmZGddde Z Gddde Z Gdd d e Z Gd d d e Z Gd d d e ZdeeeeefefdeeeeffddZdS)zkTools for working with `collations`_. .. _collations: http://userguide.icu-project.org/collation/concepts )AnyDictMappingOptionalUnion)commonc@s,eZdZdZdZ dZ dZ dZ dZdS)CollationStrengthzd An enum that defines values for `strength` on a :class:`~pymongo.collation.Collation`. N) __name__ __module__ __qualname____doc__ZPRIMARYZ SECONDARYZTERTIARYZ QUATERNARYZ IDENTICALrr8/tmp/pip-target-onvjaxws/lib/python/pymongo/collation.pyrsrc@eZdZdZdZ dZdS)CollationAlternateze An enum that defines values for `alternate` on a :class:`~pymongo.collation.Collation`. z non-ignorableZshiftedN)rrrrZ NON_IGNORABLEZSHIFTEDrrrrr. rc@r)CollationMaxVariablezh An enum that defines values for `max_variable` on a :class:`~pymongo.collation.Collation`. punctspaceN)rrrrZPUNCTSPACErrrrrArrc@s eZdZdZdZ dZ dZdS)CollationCaseFirstzf An enum that defines values for `case_first` on a :class:`~pymongo.collation.Collation`. upperloweroffN)rrrrZUPPERZLOWERZOFFrrrrrNsrc@seZdZdZdZ        ddedeedeedeedeed eed eed eed eed e ddfddZ e de ee ffddZ ddZde defddZde defddZdS) 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 __documentNlocale caseLevel caseFirststrengthnumericOrdering alternate maxVariable normalization backwardskwargsreturnc Kstd|}d|i|_|durtd||jd<|dur%td||jd<|dur2td||jd<|dur?td||jd<|durLtd||jd<|durYtd||jd<|durftd||jd<| durstd | |jd <|j| dS) Nr r!r"r#r$r%r&r'r()rZvalidate_string_Collation__documentZvalidate_booleanZvalidate_integerupdate) selfr r!r"r#r$r%r&r'r(r)rrr__init__s.   zCollation.__init__cCs |jS)zThe document representation of this collation. .. note:: :class:`Collation` is immutable. Mutating the value of :attr:`document` does not mutate this :class:`Collation`. )r+copyr-rrrdocuments zCollation.documentcs$|jddfddDfS)Nz Collation(%s)z, c3s |] }d||fVqdS)z%s=%rNr).0keyr1rr sz%Collation.__repr__..)r1joinr0rr4r__repr__szCollation.__repr__othercCst|tr |j|jkStSN) isinstancerr1NotImplementedr-r8rrr__eq__s  zCollation.__eq__cCs ||k Sr9rr<rrr__ne__s zCollation.__ne__)NNNNNNNN)rrrr __slots__strrboolintrr.propertyrr1r7r=r>rrrrr^sN:    % rvaluer*cCs2|durdSt|tr|jSt|tr|Std)NzFcollation must be a dict, an instance of collation.Collation, or None.)r:rr1dict TypeError)rDrrrvalidate_collation_or_nones  rGN)rtypingrrrrrZpymongorobjectrrrrrr@rGrrrrs  y