Ë
    4]j³$  ã                  óB  — d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZ ddlmZmZmZ ddlmZmZ  e«       Z ed«      Zdd„Z ej.                  d	ej0                  ¬
«      Zdd„Z ej.                  d«      Zddd„Zdd„Z G d„ dej<                  «      Z	 	 	 d	 	 	 	 	 	 	 	 	 dd„Ze Z! G d„ dejD                  «      Z#ejH                  Z$ejJ                  Z%ejL                  Z&ejN                  Z'ejP                  Z(ejR                  Z)ejT                  Z*dd„Z+y)zš
babel.util
~~~~~~~~~~

Various utility classes and functions.

:copyright: (c) 2013-2026 by the Babel Team.
:license: BSD, see LICENSE for more details.
é    )ÚannotationsN)Ú	GeneratorÚIterable)ÚIOÚAnyÚTypeVar)ÚdatesÚ	localtimeÚ_Tc              #  ó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      úA/var/www/zogu/zoguvenv/lib/python3.12/site-packages/babel/util.pyÚdistinctr      s:   è ø€ ô ‹5€DÜ�X“ò ˆØ�tÒØŠJØ�H‰H�T�Nñùs   ‚8 8s(   [ \t\f]* \# .* coding[=:][ \t]*([-\w.]+))Úflagsc                ó$  — | j                  «       }| j                  d«       	 | j                  «       }|j                  t        j
                  «      }|r|t        t        j
                  «      d }t        j                  |«      }|sJ	 ddl	}|j                  |j                  d«      «       | j                  «       }t        j                  |«      }|rI|r4|j                  d«      j                  d«      }|dk7  rt        d|› d�«      ‚	 | 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: z	 with BOM)ÚtellÚseekÚreadlineÚ
startswithÚcodecsÚBOM_UTF8ÚlenÚPYTHON_MAGIC_COMMENT_reÚmatchÚastÚparseÚdecodeÚImportErrorÚSyntaxErrorÚUnicodeEncodeErrorÚgroup)ÚfpÚposÚline1Úhas_bomÚmr"   Úline2Úmagic_comment_encodings           r   Úparse_encodingr0   8   sW  € ð �'‰'‹)€CØ‡G�GˆA„Jð!Ø—‘“ˆØ×"Ñ"¤6§?¡?Ó3ˆÙØœ#œfŸo™oÓ.Ð0Ð1ˆEä#×)Ñ)¨%Ó0ˆÙð9Ûà—	‘	˜%Ÿ,™, yÓ1Ô2ð Ÿ™›�Ü+×1Ñ1°%Ó8�áÙØ)*¯©°«×):Ñ):¸9Ó)EÐ&Ø)¨WÒ4Ü%Ð(:Ð;QÐ:RÐR[Ð&\Ó]Ð]Øð 	�‰��ñ Ø—7‘7˜1“:×$Ñ$ YÓ/ð 	�‰��ð à
�‰��øô+  ¤Ô.@ÐAò ñ
 ðûð* 	�‰��ús7   £A$E< Â$E" Â,AE< Ä!E< Å"E9Å6E< Å8E9Å9E< Å<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)   Úencodingr4   r*   r   Úbodyr-   ÚxÚnamesÚnameÚfeatures              r   Úparse_future_flagsrD   l   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�|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   Ú	enumerater6   r:   ÚappendÚescaper!   ÚjoinÚreplaceÚosÚsep)ÚpatternÚfilenameÚsymbolsÚbufÚidxÚpartr!   s          r   Ú	pathmatchrZ   �   só   € ðN ØØØØØñ€Gð ×Ñ˜#ÔØˆeˆØ˜!˜"�+‰Ø	×	Ñ	˜DÔ	!ØˆeˆØ˜!˜"�+‰àˆäœrŸx™x¨°WÓ=Ó>ò (‰	ˆˆTØ�Š7Ø�J‰J�w˜t‘}Õ%ÚØ�J‰J”r—y‘y “Õ'ð	(ô
 �H‰H˜Ÿ™ ›�~ QÐ'¨×)9Ñ)9¼"¿&¹&À#Ó)FÓG€EØ˜ÐÐó    c                  óf   ‡ — e Zd Z ej                  d«      Z ej                  d«      Zˆ fd„Zˆ xZS )ÚTextWrapperz((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))z$(\u2068[^\u2068]+?\u2069(?::-?\d+)?)c                ó.  •— d}||vrt         ‰| �  |«      S g }t        j                  | j                  |«      D ]C  }|j                  |«      r|j                  |«       Œ&|j                  t         ‰| �  |«      «       ŒE |D �cg c]  }|sŒ|‘Œ	 c}S c c}w )z|Splits the text into indivisible chunks while ensuring that file names
        containing spaces are not broken up.
        u   â�¨)ÚsuperÚ_splitr6   r:   Ú_enclosed_filename_rer   rN   Úextend)ÚselfÚtextÚenclosed_filename_startÚchunksÚchunkÚcÚ	__class__s         €r   r`   zTextWrapper._split×   s�   ø€ ð #+ÐØ"¨$Ñ.ä‘7‘> $Ó'Ð'àˆÜ—X‘X˜d×8Ñ8¸$Ó?ò 	5ˆEØ×ÑÐ 7Ô8Ø—‘˜eÕ$à—‘œe™g™n¨UÓ3Õ4ð		5ð
 "Ö'�a¢Q’Ò'Ð'ùÒ's   ÂBÂB)	Ú__name__Ú
__module__Ú__qualname__r6   ÚcompileÚ
wordsep_rera   r`   Ú__classcell__)ri   s   @r   r]   r]   Î   s6   ø„ Ø�—‘ð	/ó€Jð '˜BŸJ™JÐ'NÓOÐ÷(ð (r[   r]   c                óv   — t        j                  dt        d¬«       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. It also
    does not wrap PO file locations containing spaces.

    :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
    z¦`babel.util.wraptext` is deprecated and will be removed in a future version of Babel. If you need this functionality, use the `babel.util.TextWrapper` class directly.rI   ©Ú
stacklevelF)ÚwidthÚinitial_indentÚsubsequent_indentÚbreak_long_words)ÚwarningsÚwarnÚDeprecationWarningr]   Úwrap)rd   rs   rt   ru   s       r   Úwraptextr{   é   sB   € ô" ‡M�Mð	[äØõ	ô ØØ%Ø+Øô	÷
 �dˆ4ƒjðr[   c                  óB   — e Zd ZdZd	d
d„Zdd„Zdd„Zdd„Zdd„Zdd„Z	y)ÚFixedOffsetTimezonezw
    Fixed offset in minutes east from UTC.

    DEPRECATED: Use the standard library `datetime.timezone` instead.
    Nc                óŽ   — t        j                  dt        d¬«       t        j                  |¬«      | _        |€d|z  }|| _        y )Nz‰`FixedOffsetTimezone` is deprecated and will be removed in a future version of Babel. Use the standard library `datetime.timezone` class.rI   rq   )Úminutesz
Etc/GMT%+d)rw   rx   ry   ÚdatetimeÚ	timedeltaÚ_offsetÚzone)rc   ÚoffsetrB   s      r   Ú__init__zFixedOffsetTimezone.__init__  sD   € Ü�‰ðBäØõ		
ô  ×)Ñ)°&Ô9ˆŒØˆ<Ø &Ñ(ˆDØˆ�	r[   c                ó   — | j                   S ©N©rƒ   ©rc   s    r   Ú__str__zFixedOffsetTimezone.__str__!  ó   € Ø�y‰yÐr[   c                ó<   — d| j                   › d| j                  › d�S )Nz<FixedOffset "z" ú>)rƒ   r‚   r‰   s    r   Ú__repr__zFixedOffsetTimezone.__repr__$  s   € Ø §	¡	˜{¨"¨T¯\©\¨N¸!Ð<Ð<r[   c                ó   — | j                   S r‡   )r‚   ©rc   Údts     r   Ú	utcoffsetzFixedOffsetTimezone.utcoffset'  s   € Ø�|‰|Ðr[   c                ó   — | j                   S r‡   rˆ   r�   s     r   ÚtznamezFixedOffsetTimezone.tzname*  r‹   r[   c                ó   — t         S r‡   )ÚZEROr�   s     r   ÚdstzFixedOffsetTimezone.dst-  s   € Üˆr[   r‡   )r„   ÚfloatrB   ú
str | NoneÚreturnÚNone)rš   Ústr)r‘   údatetime.datetimerš   zdatetime.timedelta)r‘   r�   rš   rœ   )
rj   rk   rl   Ú__doc__r…   rŠ   rŽ   r’   r”   r—   © r[   r   r}   r}     s%   „ ñô
óó=óóôr[   r}   c                ó   — | |kD  | |k  z
  S r‡   rŸ   )ÚaÚbs     r   Ú_cmpr£   =  s   € Ø�‰E�a˜!‘eÑÐr[   )r   zIterable[_T]rš   zGenerator[_T, None, None])r)   ú	IO[bytes]rš   r™   )r   )r)   r¤   r>   rœ   rš   Úint)rT   rœ   rU   rœ   rš   Úbool)éF   rJ   rJ   )
rd   rœ   rs   r¥   rt   rœ   ru   rœ   rš   z	list[str])r¡   r   r¢   r   ),rž   r4   r   r   r€   rR   r6   Útextwraprw   Úcollections.abcr   r   Útypingr   r   r   Úbabelr	   r
   ÚobjectÚmissingr   r   rm   ÚVERBOSEr    r0   r8   rD   rZ   r]   r{   ÚdictÚodictÚtzinfor}   ÚUTCÚLOCALTZÚget_localzoneÚ	STDOFFSETÚ	DSTOFFSETÚDSTDIFFr–   r£   rŸ   r[   r   ú<module>r¸      s<  ðñõ #ã Û Û 	Û 	Û Û ß /ß #Ñ #ç "á
‹(€áˆTƒ]€óð* %˜"Ÿ*™*Ø0Ø
�*‰*ôÐ ó.ðb %˜"Ÿ*™*Ð%OÓPÐ ôóB>ôB(�(×&Ñ&ô (ð: ØØð	Ø
ðàðð ðð ð	ð
 óð@ 	€ô"˜(Ÿ/™/ô "ðP ‡i�i€Ø
�-‰-€Ø×'Ñ'€Ø×Ñ€	Ø×Ñ€	Ø
×
Ñ
€Ø‡~�~€ôr[   