
    ̆ho#                    8   S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
Jr  SSKJrJrJr  SSKJrJr  \" 5       r\" S5      rSS jr\R.                  " S	\R0                  5      rSS
 jr\R.                  " S5      rSSS jjrSS jr " S S\R<                  5      rSSS jjr\ r! " S S\RD                  5      r#\RH                  r$\RJ                  r%\RL                  r&\RN                  r'\RP                  r(\RR                  r)\RT                  r*SS jr+g)z
babel.util
~~~~~~~~~~

Various utility classes and functions.

:copyright: (c) 2013-2025 by the Babel Team.
:license: BSD, see LICENSE for more details.
    )annotationsN)	GeneratorIterable)IOAnyTypeVar)dates	localtime_Tc              #  |   #    [        5       n[        U 5       H  nX!;  d  M
  Uv   UR                  U5        M!     g7f)av  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      B/opt/services/DDDS/venv/lib/python3.13/site-packages/babel/util.pydistinctr      s2      5DXJHHTN s   <<s(   [ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c                Z   U R                  5       nU R                  S5         U R                  5       nUR                  [        R
                  5      nU(       a  U[        [        R
                  5      S n[        R                  U5      nU(       dJ   SSK	nUR                  UR                  S5      5        U R                  5       n[        R                  U5      nU(       aO  U(       a5  UR                  S5      R                  S5      nUS:w  a  [        SU S35      e U R                  U5        gU(       a1  UR                  S5      R                  S5      U R                  U5        $  U R                  U5        g! [        [        [        4 a     Nf = f! U R                  U5        f = f)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_encodingr/   5   sW    '')CGGAJ ""6??3#foo./0E#))%09		%,,y12 +11%8)*):):9)E&)W4%(:;Q:RR[&\]] 	 771:$$Y/ 	 
+  .@A 
 * 	s7   A.F $E< 6A(F 1&F <FF FF F*z'from\s+__future__\s+import\s+\(*(.+)\)*c                   SSK nU R                  5       nU R                  S5        Sn U R                  5       R	                  U5      n[
        R                  " SSU5      n[
        R                  " SSU5      n[
        R                  " SSU5      n[        R                  U5       H{  nUR                  S	5      R                  S
5       Vs/ s H!  owR                  5       R                  S5      PM#     nnU H&  n	[        X)S5      n
U
(       d  M  XJR                  -  nM(     M}     U R                  U5        U$ s  snf ! U R                  U5        f = f)zJParse 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(   encodingr3   r)   flagsbodyr,   xnamesnamefeatures              r   parse_future_flagsrD   i   s    
'')CGGAJEwwy) vv+Z>vvndD1vvosD1(11$7A45GGAJ4D4DS4IJ4IqWWY__T*4IEJ!*D97222E  8 	L K 	s$   B!D< 
(D72D< D< 7D< <Ec                   SSSSSSS.nU R                  S5      (       a	  S/nU S	S
 n O!U R                  S5      (       a	  S/nU SS
 n O/ n[        [        R                  " SU 5      5       HR  u  pEUS-  (       a  UR	                  X%   5        M$  U(       d  M-  UR	                  [        R
                  " U5      5        MT     [        R                  " SR                  U5       S3UR                  [        R                  S5      5      nUS
L$ )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   	enumerater5   r9   appendescaper    joinreplaceossep)patternfilenamesymbolsbufidxpartr    s          r   	pathmatchrZ      s    N G #e!"+			D	!	!e!"+rxxW=>	7JJw}%TJJryy'	 ?
 HH~Q')9)9"&&#)FGE    c                  p   ^  \ rS rSr\R
                  " S5      r\R
                  " S5      rU 4S jrSr	U =r
$ )TextWrapper   z((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))z$(\u2068[^\u2068]+?\u2069(?::-?\d+)?)c                R  > SnX!;  a  [         TU ]  U5      $ / n[        R                  " U R                  U5       HJ  nUR                  U5      (       a  UR                  U5        M,  UR                  [         TU ]  U5      5        ML     U Vs/ s H  oU(       d  M  UPM     sn$ s  snf )zlSplits the text into indivisible chunks while ensuring that file names
containing spaces are not broken up.
u   ⁨)super_splitr5   r9   _enclosed_filename_rer   rN   extend)selftextenclosed_filename_startchunkschunkc	__class__s         r   ra   TextWrapper._split   s     #+".7>$''XXd88$?E 788e$egnU34	 @
 "'6aQ6'''s   
B$B$ )__name__
__module____qualname____firstlineno__r5   compile
wordsep_rerb   ra   __static_attributes____classcell__)rj   s   @r   r]   r]      s2    	/J JJ'NO( (r[   r]   c                n    [         R                  " S[        SS9  [        XUSS9nUR	                  U 5      $ )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)re   rw   rx   ry   wrappers        r   wraptextr      sA     MM	[	 ,=+02G <<r[   c                  X    \ rS rSrSrSSS jjrSS jrSS jrSS jrSS jr	SS	 jr
S
rg)FixedOffsetTimezonei  z&Fixed offset in minutes east from UTC.Nc                R    [         R                  " US9U l        Uc  SU-  nX l        g )N)minutesz
Etc/GMT%+d)datetime	timedelta_offsetzone)rd   offsetrB   s      r   __init__FixedOffsetTimezone.__init__  s(    ))&9<&(D	r[   c                    U R                   $ Nr   rd   s    r   __str__FixedOffsetTimezone.__str__      yyr[   c                <    SU R                    SU R                   S3$ )Nz<FixedOffset "z" >)r   r   r   s    r   __repr__FixedOffsetTimezone.__repr__  s    		{"T\\N!<<r[   c                    U R                   $ r   )r   rd   dts     r   	utcoffsetFixedOffsetTimezone.utcoffset  s    ||r[   c                    U R                   $ r   r   r   s     r   tznameFixedOffsetTimezone.tzname  r   r[   c                    [         $ r   )ZEROr   s     r   dstFixedOffsetTimezone.dst  s    r[   )r   r   r   )r   floatrB   
str | NonereturnNone)r   str)r   datetime.datetimer   zdatetime.timedelta)r   r   r   r   )rm   rn   ro   rp   __doc__r   r   r   r   r   r   rs   rl   r[   r   r   r     s#    0=r[   r   c                    X:  X:  -
  $ r   rl   )abs     r   _cmpr   '  s    Eae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   )
re   r   rw   r   rx   r   ry   r   r   z	list[str])r   r   r   r   ),r   r3   r   r   r   rR   r5   textwrapr{   collections.abcr   r   typingr   r   r   babelr	   r
   objectmissingr   r   rq   VERBOSEr   r/   r7   rD   rZ   r]   r   dictodicttzinfor   UTCLOCALTZget_localzone	STDOFFSET	DSTOFFSETDSTDIFFr   r   rl   r[   r   <module>r      s    #   	 	   / # # "
(T]* **0"**> -` **.0 @>B((&& (62 	(// : ii
--''		


~~r[   