Ë
    V¼Sf30  ã                   óX  — d Z ddlmZ ddlZddlmZ dZdZdZdZ	d	Z
e
d
z  ZdZe
ez   Z ej                  d«      Z ej                  d«      Zg d¢Zdj%                  d„ eD «       «      Z ej                  e«      Zdefd„Zdefd„Zdefd„Zdee   fd„ZeZdedefd„Z G d„ de«      Zy)zBUtilities for managing / converting field paths to / from strings.é    )ÚabcN)ÚIterablez!{!r} is not contained in the dataz2{!r} is not contained in the data for the key {!r}zGThe data at {!r} is not a dictionary, so it cannot contain the key {!r}ú.ú\é   ú`z^[_a-zA-Z][_a-zA-Z0-9]*$z$^[_a-zA-Z][_a-zA-Z0-9]*[^_a-zA-Z0-9]))ÚSIMPLEz[_a-zA-Z][_a-zA-Z0-9]*)ÚQUOTEDz`(?:\\`|[^`])*?`)ÚDOTz\.ú|c              #   ó:   K  — | ]  } d j                   |Ž –— Œ y­w)z
(?P<{}>{})N)Úformat)Ú.0Úpairs     úcC:\Users\user\Documents\project_loop\venv\Lib\site-packages\google/cloud/firestore_v1/field_path.pyú	<genexpr>r   *   s   è ø€ ÒU¸Ð-˜,×-Ñ-¨tÔ4ÑUùs   ‚Úpathc              #   ó  K  — d}t         j                  } || «      }|�=|j                  }|j                  |«      }|–— |j	                  «       } || |«      }|�Œ=|t        | «      k7  rt        dj                  | | |d «      «      ‚y­w)z‘Lex a field path into tokens (including dots).

    Args:
        path (str): field path to be lexed.
    Returns:
        List(str): tokens
    r   Nz!Path {} not consumed, residue: {})ÚTOKENS_REGEXÚmatchÚ	lastgroupÚgroupÚendÚlenÚ
ValueErrorr   )r   ÚposÚ	get_tokenr   Útype_Úvalues         r   Ú_tokenize_field_pathr    .   s”   è ø€ ð €CÜ×"Ñ"€IÙ�d‹O€EØ
Ð
Ø—‘ˆØ—‘˜EÓ"ˆØŠØ�i‰i‹kˆÙ˜$ Ó$ˆð Ñ
ð Œc�$‹iÒÜÐ<×CÑCÀDÈ$ÈsÈtÈ*ÓUÓVÐVð ùs   ‚AB	Á-B	c                 ó  — | sg S g }d}t        | «      D ]X  }|r"|dk7  rt        dj                  | «      «      ‚d}Œ'|dk(  rt        dj                  | «      «      ‚|j                  |«       d}ŒZ |r|st        dj                  | «      «      ‚|S )a  Split a field path into valid elements (without dots).

    Args:
        path (str): field path to be lexed.
    Returns:
        List(str): tokens
    Raises:
        ValueError: if the path does not match the elements-interspersed-
                    with-dots pattern.
    Fr   zInvalid path: {}T)r    r   r   Úappend)r   ÚelementsÚwant_dotÚelements       r   Úsplit_field_pathr&   C   s¢   € ñ Øˆ	à€HØ€Hä'¨Ó-ò 
ˆÙØ˜#Š~Ü Ð!3×!:Ñ!:¸4Ó!@ÓAÐAà ‘à˜#Š~Ü Ð!3×!:Ñ!:¸4Ó!@ÓAÐAØ�O‰O˜GÔ$Ø‰Hð
ñ ™8ÜÐ+×2Ñ2°4Ó8Ó9Ð9à€Oó    Úapi_reprc                 óÞ   — g }t        | «      D ]\  }|d   dk(  rA|d   dk(  r9|dd }|j                  t        t        «      }|j                  t        t
        «      }|j                  |«       Œ^ |S )a;  Parse a **field path** from into a list of nested field names.

    See :func:`field_path` for more on **field paths**.

    Args:
        api_repr (str):
            The unique Firestore api representation which consists of
            either simple or UTF-8 field names. It cannot exceed
            1500 bytes, and cannot be empty. Simple field names match
            ``'^[_a-zA-Z][_a-zA-Z0-9]*$'``. All other field names are
            escaped by surrounding them with backticks.

    Returns:
        List[str, ...]: The list of field names in the field path.
    r   r   éÿÿÿÿé   )r&   ÚreplaceÚ_ESCAPED_BACKTICKÚ	_BACKTICKÚ_ESCAPED_BACKSLASHÚ
_BACKSLASHr"   )r(   Úfield_namesÚ
field_names      r   Úparse_field_pathr3   f   s|   € ð$ €KÜ& xÓ0ò 'ˆ
à�a‰=˜CÒ J¨r¡N°cÒ$9Ø# A bÐ)ˆJØ#×+Ñ+Ô,=¼yÓIˆJØ#×+Ñ+Ô,>Ä
ÓKˆJØ×Ñ˜:Õ&ð'ð Ðr'   r1   c                 óZ  — g }| D ]�  }t         j                  |«      }|r&|j                  d«      |k(  r|j                  |«       Œ@|j	                  t
        t        «      j	                  t        t        «      }|j                  t        |z   t        z   «       Œ’ t        j                  |«      S )aC  Create a **field path** from a list of nested field names.

    A **field path** is a ``.``-delimited concatenation of the field
    names. It is used to represent a nested field. For example,
    in the data

    .. code-block:: python

       data = {
          'aa': {
              'bb': {
                  'cc': 10,
              },
          },
       }

    the field path ``'aa.bb.cc'`` represents that data stored in
    ``data['aa']['bb']['cc']``.

    Args:
        field_names: The list of field names.

    Returns:
        str: The ``.``-delimited field path.
    r   )Ú_SIMPLE_FIELD_NAMEr   r   r"   r,   r0   r/   r.   r-   Ú_FIELD_PATH_DELIMITERÚjoin)r1   Úresultr2   r   Úreplaceds        r   Úrender_field_pathr:   ƒ   s•   € ð4 €Fà!ò <ˆ
Ü"×(Ñ(¨Ó4ˆÙ�U—[‘[ “^ zÒ1Ø�M‰M˜*Õ%à!×)Ñ)¬*Ô6HÓI×QÑQÜÔ,óˆHð �M‰Mœ) hÑ.´Ñ:Õ;ð<ô !×%Ñ% fÓ-Ð-r'   Ú
field_pathÚdatac                 ó’  — t        | «      }|}t        |«      D ]«  \  }}t        |t        j                  «      r^||v r||   }Œ*|dk(  r t
        j                  |«      }t        |«      ‚t        |d| «      }t        j                  ||«      }t        |«      ‚t        |d| «      }t        j                  ||«      }t        |«      ‚ |S )a  Get a (potentially nested) value from a dictionary.

    If the data is nested, for example:

    .. code-block:: python

       >>> data
       {
           'top1': {
               'middle2': {
                   'bottom3': 20,
                   'bottom4': 22,
               },
               'middle5': True,
           },
           'top6': b'  foo',
       }

    a **field path** can be used to access the nested data. For
    example:

    .. code-block:: python

       >>> get_nested_value('top1', data)
       {
           'middle2': {
               'bottom3': 20,
               'bottom4': 22,
           },
           'middle5': True,
       }
       >>> get_nested_value('top1.middle2', data)
       {
           'bottom3': 20,
           'bottom4': 22,
       }
       >>> get_nested_value('top1.middle2.bottom3', data)
       20

    See :meth:`~google.cloud.firestore_v1.client.Client.field_path` for
    more information on **field paths**.

    Args:
        field_path (str): A field path (``.``-delimited list of
            field names).
        data (Dict[str, Any]): The (possibly nested) data.

    Returns:
        Any: (A copy of) the value stored for the ``field_path``.

    Raises:
        KeyError: If the ``field_path`` does not match nested data.
    r   N)r3   Ú	enumerateÚ
isinstancer   ÚMappingÚ_FIELD_PATH_MISSING_TOPr   ÚKeyErrorr:   Ú_FIELD_PATH_MISSING_KEYÚ_FIELD_PATH_WRONG_TYPE)r;   r<   r1   Únested_dataÚindexr2   ÚmsgÚpartials           r   Úget_nested_valuerI   ¯   sÐ   € ôl # :Ó.€Kà€KÜ& {Ó3ò  ÑˆˆzÜ�k¤3§;¡;Ô/Ø˜[Ñ(Ø)¨*Ñ5‘à˜A’:Ü1×8Ñ8¸ÓD�CÜ" 3›-Ð'ä/°¸F¸UÐ0CÓD�GÜ1×8Ñ8¸ÀWÓM�CÜ" 3›-Ð'ä'¨°F°UÐ(;Ó<ˆGÜ(×/Ñ/°¸ÓDˆCÜ˜3“-Ðð ð" Ðr'   c                   ó‚   — e Zd ZdZd„ Zedefd„«       Zedefd„«       Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zy)Ú	FieldPathaÛ  Field Path object for client use.

    A field path is a sequence of element keys, separated by periods.
    Each element key can be either a simple identifier, or a full unicode
    string.

    In the string representation of a field path, non-identifier elements
    must be quoted using backticks, with internal backticks and backslashes
    escaped with a backslash.

    Args:
        parts: (one or more strings)
            Indicating path of the key to be used.
    c                 óp   — |D ]!  }t        |t        «      r|rŒd}t        |«      ‚ t        |«      | _        y )Nz3One or more components is not a string or is empty.)r?   Ústrr   ÚtupleÚparts)ÚselfrO   ÚpartÚerrors       r   Ú__init__zFieldPath.__init__  s:   € Øò 	(ˆDÜ˜d¤CÔ(²ØM�Ü  Ó'Ð'ð	(ô ˜5“\ˆ�
r'   r(   c                 óX   — |j                  «       }|st        d«      ‚ | t        |«      Ž S )a€  Factory: create a FieldPath from the string formatted per the API.

        Args:
            api_repr (str): a string path, with non-identifier elements quoted
            It cannot exceed 1500 characters, and cannot be empty.
        Returns:
            (:class:`FieldPath`) An instance parsed from ``api_repr``.
        Raises:
            ValueError if the parsing fails
        z.Field path API representation cannot be empty.)Ústripr   r3   )Úclsr(   s     r   Úfrom_api_reprzFieldPath.from_api_repr  s0   € ð —>‘>Ó#ˆÙÜÐMÓNÐNÙÔ$ XÓ.Ð/Ð/r'   Úpath_stringc                 óü   — 	 | j                  |«      S # t        $ r_ |j                  d«      }|D ]>  }|st        d«      ‚t        j	                  |«      sŒ&t        dj                  |«      «      ‚ t        |Ž cY S w xY w)a  Factory: create a FieldPath from a unicode string representation.

        This method splits on the character `.` and disallows the
        characters `~*/[]`. To create a FieldPath whose components have
        those characters, call the constructor.

        Args:
            path_string (str): A unicode string which cannot contain
            `~*/[]` characters, cannot exceed 1500 bytes, and cannot be empty.

        Returns:
            (:class:`FieldPath`) An instance parsed from ``path_string``.
        r   zEmpty elementz3Non-alphanum char in element with leading alpha: {})rW   r   ÚsplitÚ_LEADING_ALPHA_INVALIDr   r   rK   )rV   rX   r#   r%   s       r   Úfrom_stringzFieldPath.from_string$  s�   € ð	(Ø×$Ñ$ [Ó1Ð1øÜò 	(Ø"×(Ñ(¨Ó-ˆHØ#ò �ÙÜ$ _Ó5Ð5Ü)×/Ñ/°Õ8Ü$ØM×TÑTØ#óóð ð	ô ˜hÐ'Ò'ð	(ús   ‚ “AA;Á#A;Á:A;c                 ój   — d}| j                   D ]  }|d|z   dz   z  }Œ |d d }dj                  |«      S )NÚ ú'z',r*   zFieldPath({}))rO   r   )rP   ÚpathsrQ   s      r   Ú__repr__zFieldPath.__repr__B  sI   € ØˆØ—J‘Jò 	'ˆDØ�S˜4‘Z $Ñ&Ñ&‰Eð	'à�c�r�
ˆØ×%Ñ% eÓ,Ð,r'   c                 ó4   — t        | j                  «       «      S ©N)ÚhashÚto_api_repr©rP   s    r   Ú__hash__zFieldPath.__hash__I  s   € Ü�D×$Ñ$Ó&Ó'Ð'r'   c                 ó`   — t        |t        «      r| j                  |j                  k(  S t        S rc   ©r?   rK   rO   ÚNotImplemented©rP   Úothers     r   Ú__eq__zFieldPath.__eq__L  s%   € Ü�eœYÔ'Ø—:‘: §¡Ñ,Ð,ÜÐr'   c                 ó`   — t        |t        «      r| j                  |j                  k  S t        S rc   ri   rk   s     r   Ú__lt__zFieldPath.__lt__Q  s%   € Ü�eœYÔ'Ø—:‘: §¡Ñ+Ð+ÜÐr'   c                 óø   — t        |t        «      r!| j                  |j                  z   }t        |Ž S t        |t        «      r4| j                  t        j	                  |«      j                  z   }t        |Ž S t
        S )zØAdds `other` field path to end of this field path.

        Args:
            other (~google.cloud.firestore_v1._helpers.FieldPath, str):
                The field path to add to the end of this `FieldPath`.
        )r?   rK   rO   rM   r\   rj   )rP   rl   rO   s      r   Ú__add__zFieldPath.__add__V  se   € ô �eœYÔ'Ø—J‘J §¡Ñ,ˆEÜ˜eÐ$Ð$Ü˜œsÔ#Ø—J‘J¤×!6Ñ!6°uÓ!=×!CÑ!CÑCˆEÜ˜eÐ$Ð$ä!Ð!r'   c                 ó,   — t        | j                  «      S )z¶Render a quoted string representation of the FieldPath

        Returns:
            (str) Quoted string representation of the path stored
            within this FieldPath.
        )r:   rO   rf   s    r   re   zFieldPath.to_api_reprf  s   € ô ! §¡Ó,Ð,r'   c                 óŒ   — | j                   dt        |j                   «       |j                   dt        | j                   «       k(  S )z¥Check whether ``other`` is an ancestor.

        Returns:
            (bool) True IFF ``other`` is an ancestor or equal to ``self``,
            else False.
        N)rO   r   rk   s     r   Úeq_or_parentzFieldPath.eq_or_parento  s8   € ð �z‰zÐ,œC §¡Ó,Ð-°·±Ð=N¼sÀ4Ç:Á:»Ð1OÑOÐOr'   c                 ó�   — t        dt        | j                  «      «      }|D �ch c]  }t        | j                  d| Ž ’Œ c}S c c}w )zVReturn field paths for all parents.

        Returns: Set[:class:`FieldPath`]
        r+   N)Úranger   rO   rK   )rP   ÚindexesrF   s      r   ÚlineagezFieldPath.lineagex  s<   € ô
 ˜œ3˜tŸz™z›?Ó+ˆØ<CÖD°5”	˜4Ÿ:™: f uÐ-Ò.ÒDÐDùÒDs   ¤Ac                   ó   — y)zÜA special FieldPath value to refer to the ID of a document. It can be used
           in queries to sort or filter by the document ID.

        Returns: A special sentinel value to refer to the ID of a document.
        Ú__name__© r{   r'   r   Údocument_idzFieldPath.document_id€  s   € ð r'   N)rz   Ú
__module__Ú__qualname__Ú__doc__rS   ÚclassmethodrM   rW   r\   ra   rg   rm   ro   rq   re   rt   rx   Ústaticmethodr|   r{   r'   r   rK   rK   ü   s€   „ ñò"ð ð0 Sò 0ó ð0ð  ð( cò (ó ð(ò:-ò(òò
ò
"ò -òPòEð ñó ñr'   rK   )r   Úcollectionsr   ÚreÚtypingr   rA   rC   rD   r6   r0   r/   r.   r-   Úcompiler5   r[   ÚPATH_ELEMENT_TOKENSr7   ÚTOKENS_PATTERNr   rM   r    r&   r3   r:   Úget_field_pathÚdictrI   ÚobjectrK   r{   r'   r   ú<module>r‹      s  ðñ Iå ã 	Ý ð >Ð ØNÐ àMð ð Ð Ø€
Ø !‘^Ð Ø€	Ø Ñ*Ð à�R—Z‘ZÐ :Ó;Ð Ø#˜Ÿ™Ð$JÓKÐ òÐ ð
 —‘ÑUÐATÔUÓU€Øˆr�z‰z˜.Ó)€ðW˜só Wð* ˜3ó  ðF˜só ð:&. 8¨C¡=ó &.ðR #€ðJ ð J¨Dó JôZK�õ Kr'   