Ë
    ÆªbŠ  ã                   óè  — d Z ddlZddlZddlmZmZ ddlZddlZddlZddl	Z
ddlmZ  e«       Zd„ Z ej                   dej"                  «      Zd„ Z ej                   d«      Zdd	„Zd
„ Z G d„ dej.                  «      Zdd„Zej2                  Z G d„ de«      Ze
j8                  Zej<                  Zej>                  Zej@                  Z ejB                  Z!ejD                  Z"ejF                  Z#d„ Z$y)z®
    babel.util
    ~~~~~~~~~~

    Various utility classes and functions.

    :copyright: (c) 2013-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
é    N)Ú	timedeltaÚtzinfo)Ú	localtimec              #   ót   K  — t        «       }t        | «      D ]  }||vsŒ|–— |j                  |«       Œ y­w)a–  Yield all items in an iterable collection that are distinct.

    Unlike when using sets for a similar effect, the original ordering of the
    items in the collection is preserved by this function.

    >>> print(list(distinct([1, 2, 1, 3, 4, 4])))
    [1, 2, 3, 4]
    >>> print(list(distinct('foobar')))
    ['f', 'o', 'b', 'a', 'r']

    :param iterable: the iterable collection providing the data
    N)ÚsetÚiterÚadd)ÚiterableÚseenÚitems      ú,/usr/lib/python3/dist-packages/babel/util.pyÚdistinctr      s:   è ø€ ô ‹5€DÜ�X“ò ˆØ�tÒØŠJØ�H‰H�T�Nñùs   ‚8 8s(   [ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c                 ó:  — | j                  «       }| j                  d«       	 | j                  «       }|j                  t        j
                  «      }|r|t        t        j
                  «      d }t        j                  |«      }|sJ	 ddl	}|j                  |j                  d«      «       | j                  «       }t        j                  |«      }|rT|r?|j                  d«      j                  d«      }|dk7  rt        dj!                  |«      «      ‚	 | j                  |«       y|r1|j                  d«      j                  d«      | j                  |«       S 	 | j                  |«       y# t        t        t        f$ r Y Œ²w xY w# | j                  |«       w xY w)a/  Deduce the encoding of a source file from magic comment.

    It does this in the same way as the `Python interpreter`__

    .. __: https://docs.python.org/3.4/reference/lexical_analysis.html#encoding-declarations

    The ``fp`` argument should be a seekable file object.

    (From Jeff Dairiki)
    r   Núlatin-1é   zutf-8zencoding problem: {0} with BOM)ÚtellÚseekÚreadlineÚ
startswithÚcodecsÚBOM_UTF8ÚlenÚPYTHON_MAGIC_COMMENT_reÚmatchÚastÚparseÚdecodeÚImportErrorÚSyntaxErrorÚUnicodeEncodeErrorÚgroupÚformat)ÚfpÚposÚline1Úhas_bomÚmr   Úline2Úmagic_comment_encodings           r   Úparse_encodingr*   /   s_  € ð �'‰'‹)€CØ‡G�GˆA„Jð"Ø—‘“ˆØ×"Ñ"¤6§?¡?Ó3ˆÙØœ#œfŸo™oÓ.Ð/Ð0ˆEä#×)Ñ)¨%Ó0ˆÙð9ÛØ—	‘	˜%Ÿ,™, yÓ1Ô2ð Ÿ™›�Ü+×1Ñ1°%Ó8�áÙØ)*¯©°«×):Ñ):¸9Ó)EÐ&Ø)¨WÒ4Ü%Ø8×?Ñ?Ø2ó4ó5ð 5ð ð 	�‰��ñ Ø—7‘7˜1“:×$Ñ$ YÓ/ð 	�‰��ð à
�‰��øô/  ¤Ô.@ÐAò ñ
 ðûð. 	�‰��ús7   £A$F Â$E- Â,A(F Ä'!F Å-FÆF ÆFÆF ÆFz'from\s+__future__\s+import\s+\(*(.+)\)*c                 óŒ  — ddl }| j                  «       }| j                  d«       d}	 | j                  «       j	                  |«      }t        j                  dd|«      }t        j                  dd|«      }t        j                  dd|«      }t        j                  |«      D ]r  }|j                  d	«      j                  d
«      D �cg c]!  }|j                  «       j                  d«      ‘Œ# }}|D ]!  }	t        ||	d«      }
|
sŒ||
j                  z  }Œ# Œt 	 | j                  |«       |S c c}w # | j                  |«       w xY w)zRParse the compiler flags by :mod:`__future__` from the given Python
    code.
    r   Nzimport\s*\([\r\n]+zimport (z,\s*[\r\n]+z, z\\\s*[\r\n]+ú r   ú,z())Ú
__future__r   r   Úreadr   ÚreÚsubÚPYTHON_FUTURE_IMPORT_reÚfinditerr!   ÚsplitÚstripÚgetattrÚcompiler_flag)r#   Úencodingr.   r$   ÚflagsÚbodyr'   ÚxÚnamesÚnameÚfeatures              r   Úparse_future_flagsr?   e   s  € ó Ø
�'‰'‹)€CØ‡G�GˆA„JØ€EðØ�w‰w‹y×Ñ Ó)ˆô �v‰vÐ+¨Z¸Ó>ˆä�v‰v�n d¨DÓ1ˆä�v‰v�o s¨DÓ1ˆä(×1Ñ1°$Ó7ò 	3ˆAØ45·G±G¸A³J×4DÑ4DÀSÓ4IÖJ¨q�Q—W‘W“Y—_‘_ TÕ*ÐJˆEÐJØò 3�Ü! *¨d°DÓ9�ÚØ˜W×2Ñ2Ñ2‘Eñ3ñ	3ð 	�‰�ŒØ€Lùò Køð 	�‰��ús$   ©BD0 Ã&D+Ã-D0 ÄD0 Ä+D0 Ä0Ec                 óä  — dddddddœ}| j                  d«      r	dg}| d	d
 } n| j                  d«      r	dg}| dd
 } ng }t        t        j                  d| «      «      D ]F  \  }}|dz  r|j	                  ||   «       Œ |sŒ#|j	                  t        j
                  |«      «       ŒH t        j                  dj                  |«      dz   |j                  t        j                  d«      «      }|d
uS )aø  Extended pathname pattern matching.

    This function is similar to what is provided by the ``fnmatch`` module in
    the Python standard library, but:

     * can match complete (relative or absolute) path names, and not just file
       names, and
     * also supports a convenience pattern ("**") to match files at any
       directory level.

    Examples:

    >>> pathmatch('**.py', 'bar.py')
    True
    >>> pathmatch('**.py', 'foo/bar/baz.py')
    True
    >>> pathmatch('**.py', 'templates/index.html')
    False

    >>> pathmatch('./foo/**.py', 'foo/bar/baz.py')
    True
    >>> pathmatch('./foo/**.py', 'bar/baz.py')
    False

    >>> pathmatch('^foo/**.py', 'foo/bar/baz.py')
    True
    >>> pathmatch('^foo/**.py', 'bar/baz.py')
    False

    >>> pathmatch('**/templates/*.html', 'templates/index.html')
    True
    >>> pathmatch('**/templates/*.html', 'templates/foo/bar.html')
    False

    :param pattern: the glob pattern
    :param filename: the path name of the file to match against
    z[^/]z[^/]/z[^/]+z[^/]+/z	(?:.+/)*?z(?:.+/)*?[^/]+)ú?z?/Ú*z*/z**/z**ú^r   Nz./é   z	([?*]+/?)Ú ú$ú/)r   Ú	enumerater0   r4   ÚappendÚescaper   ÚjoinÚreplaceÚosÚsep)ÚpatternÚfilenameÚsymbolsÚbufÚidxÚpartr   s          r   Ú	pathmatchrU   …   sñ   € ðN ØØØØØñ€Gð ×Ñ˜#ÔØˆeˆØ˜!˜"�+‰Ø	×	Ñ	˜DÔ	!ØˆeˆØ˜!˜"�+‰àˆäœrŸx™x¨°WÓ=Ó>ò (‰	ˆˆTØ�Š7Ø�J‰J�w˜t‘}Õ%ÚØ�J‰J”r—y‘y “Õ'ð	(ô
 �H‰H�R—W‘W˜S“\ CÑ'¨×)9Ñ)9¼"¿&¹&À#Ó)FÓG€EØ˜ÐÐó    c                   ó0   — e Zd Z ej                  d«      Zy)ÚTextWrapperz((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))N)Ú__name__Ú
__module__Ú__qualname__r0   ÚcompileÚ
wordsep_re© rV   r   rX   rX   Æ   s   „ Ø�—‘ð	/ó�JrV   rX   c                 óB   — t        |||d¬«      }|j                  | «      S )aØ  Simple wrapper around the ``textwrap.wrap`` function in the standard
    library. This version does not wrap lines on hyphens in words.

    :param text: the text to wrap
    :param width: the maximum line width
    :param initial_indent: string that will be prepended to the first line of
                           wrapped output
    :param subsequent_indent: string that will be prepended to all lines save
                              the first of wrapped output
    F)ÚwidthÚinitial_indentÚsubsequent_indentÚbreak_long_words)rX   Úwrap)Útextr`   ra   rb   Úwrappers        r   Úwraptextrg   Í   s)   € ô  °nØ,=Ø+0ô2€Gð �<‰<˜ÓÐrV   c                   ó6   — e Zd ZdZd	d„Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)
ÚFixedOffsetTimezonez&Fixed offset in minutes east from UTC.Nc                 óB   — t        |¬«      | _        |€d|z  }|| _        y )N)Úminutesz
Etc/GMT%+d)r   Ú_offsetÚzone)ÚselfÚoffsetr=   s      r   Ú__init__zFixedOffsetTimezone.__init__å   s$   € Ü ¨Ô0ˆŒØˆ<Ø &Ñ(ˆDØˆ�	rV   c                 ó   — | j                   S ©N©rm   ©rn   s    r   Ú__str__zFixedOffsetTimezone.__str__ë   ó   € Ø�y‰yÐrV   c                 ó<   — d| j                   ›d| j                  ›d�S )Nz<FixedOffset "z" ú>)rm   rl   rt   s    r   Ú__repr__zFixedOffsetTimezone.__repr__î   s   � Ø*.¯)«)°T·\³\ÐBÐBrV   c                 ó   — | j                   S rr   )rl   ©rn   Údts     r   Ú	utcoffsetzFixedOffsetTimezone.utcoffsetñ   s   € Ø�|‰|ÐrV   c                 ó   — | j                   S rr   rs   r{   s     r   ÚtznamezFixedOffsetTimezone.tznameô   rv   rV   c                 ó   — t         S rr   )ÚZEROr{   s     r   ÚdstzFixedOffsetTimezone.dst÷   s   € ÜˆrV   rr   )
rY   rZ   r[   Ú__doc__rp   ru   ry   r}   r   r‚   r^   rV   r   ri   ri   â   s$   „ Ù0óòòCòòórV   ri   c                 ó   — | |kD  | |k  z
  S rr   r^   )ÚaÚbs     r   Ú_cmpr‡     s   € Ø�‰E�a˜!‘eÑÐrV   )r   )éF   rE   rE   )%rƒ   r   ÚcollectionsÚdatetimer   r   rM   r0   ÚtextwrapÚpytzÚ_pytzÚbabelr   ÚobjectÚmissingr   r\   ÚVERBOSEr   r*   r2   r?   rU   rX   rg   ÚOrderedDictÚodictri   ÚutcÚUTCÚLOCALTZÚget_localzoneÚ	STDOFFSETÚ	DSTOFFSETÚDSTDIFFr�   r‡   r^   rV   r   ú<module>r›      sô   ðñó Û ß &Û 	Û 	Û Û Ý á
‹(€òð( %˜"Ÿ*™*Ø0°"·*±*ó>Ð ò/ðd %˜"Ÿ*™*Ø.ó0Ð óò@>ôB�(×&Ñ&ô óð$ 	×Ñ€ô˜&ô ð6 ‡i�i€Ø
×
Ñ
€Ø×'Ñ'€à×Ñ€	Ø×Ñ€	Ø
×
Ñ
€Ø‡~�~€órV   