HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/babel/__pycache__/util.cpython-310.pyc
o

!we�@s2dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
mZmZddlmZmZe�Zed�Zd2dd
�Ze�dej�Zd3dd�Ze�d�Zd4d5dd�Zd6dd�ZGd d!�d!ej�Zd7d8d)d*�Zej Z!Gd+d,�d,ej"�Z#ej$Z$ej%Z%ej&Z&ej'Z'ej(Z(ej)Z)ej*Z*d9d0d1�Z+dS):z�
    babel.util
    ~~~~~~~~~~

    Various utility classes and functions.

    :copyright: (c) 2013-2023 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�)�annotationsN)�	Generator�Iterable)�IO�Any�TypeVar)�dates�	localtime�_T�iterable�Iterable[_T]�return�Generator[_T, None, None]ccs2�t�}t|�D]}||vr|V|�|�qdS)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)r�seen�item�r�C/home/arjun/projects/env/lib/python3.10/site-packages/babel/util.py�distincts�

��rs([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)�fp�	IO[bytes]�
str | Nonec
Cs|��}|�d�zx|��}|�tj�}|r|ttj�d�}t�|�}|sJzddl	}|�
|�d��Wntt
tfy@Yn
w|��}t�|�}|rj|rb|�d��d�}|dkrbt
d|�d���W|�|�dS|rz|�d��d�W|�|�SW|�|�dS|�|�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)
    rN�latin-1�zutf-8zencoding problem: z	 with BOM)�tell�seek�readline�
startswith�codecs�BOM_UTF8�len�PYTHON_MAGIC_COMMENT_re�match�ast�parse�decode�ImportError�SyntaxError�UnicodeEncodeError�group)r�pos�line1�has_bom�mr%�line2�magic_comment_encodingrrr�parse_encoding5s:

�
��r2z'from\s+__future__\s+import\s+\(*(.+)\)*r�encoding�str�intc
	Cs�ddl}|��}|�d�d}zK|���|�}t�dd|�}t�dd|�}t�dd|�}t�|�D]!}d	d
�|�	d��
d�D�}|D]}t||d�}	|	rQ||	jO}qBq1W|�|�|S|�|�w)
zRParse the compiler flags by :mod:`__future__` from the given Python
    code.
    rNzimport\s*\([\r\n]+zimport (z,\s*[\r\n]+z, z\\\s*[\r\n]+� cSsg|]	}|���d��qS)z())�strip)�.0�xrrr�
<listcomp>sz&parse_future_flags.<locals>.<listcomp>r�,)
�
__future__rr�readr'�re�sub�PYTHON_FUTURE_IMPORT_re�finditerr+�split�getattr�
compiler_flag)
rr3r<r,�flags�bodyr/�names�name�featurerrr�parse_future_flagsis*

���
�rJ�pattern�filename�boolcCs�ddddddd�}|�d�rdg}|d	d
�}n|�d�r'dg}|dd
�}ng}tt�d
|��D]\}}|drA|�||�q1|rK|�t�|��q1t�d�|��d�|�t	j
d��}|d
uS)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**�^rNz./�z	([?*]+/?)��$�/)r�	enumerater>rB�append�escaper$�join�replace�os�sep)rKrL�symbols�buf�idx�partr$rrr�	pathmatch�s,'�
	
�"r`c@seZdZe�d�ZdS)�TextWrapperz((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))N)�__name__�
__module__�__qualname__r>�compile�
wordsep_rerrrrra�s�ra�FrR�text�width�initial_indent�subsequent_indent�	list[str]cCst|||dd�}|�|�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)rirjrk�break_long_words)ra�wrap)rhrirjrk�wrapperrrr�wraptext�s
�
rpc@sNeZdZdZddd	d
�Zddd
�Zddd�Zddd�Zddd�Zddd�Z	dS)�FixedOffsetTimezonez&Fixed offset in minutes east from UTC.N�offset�floatrHrr
�NonecCs(tj|d�|_|durd|}||_dS)N)�minutesz
Etc/GMT%+d)�datetime�	timedelta�_offset�zone)�selfrrrHrrr�__init__�s
zFixedOffsetTimezone.__init__r4cC�|jS�N�ry�rzrrr�__str__��zFixedOffsetTimezone.__str__cCsd|j�d|j�d�S)Nz<FixedOffset "z" �>)ryrxrrrr�__repr__�szFixedOffsetTimezone.__repr__�dt�datetime.datetime�datetime.timedeltacCr|r})rx�rzr�rrr�	utcoffset�r�zFixedOffsetTimezone.utcoffsetcCr|r}r~r�rrr�tzname�r�zFixedOffsetTimezone.tznamecCstSr})�ZEROr�rrr�dst�szFixedOffsetTimezone.dstr})rrrsrHrr
rt)r
r4)r�r�r
r�)r�r�r
r4)
rbrcrd�__doc__r{r�r�r�r�r�rrrrrq�s



rq�ar�bcCs||k||kSr}r)r�r�rrr�_cmpsr�)rrr
r)rrr
r)r)rrr3r4r
r5)rKr4rLr4r
rM)rgrRrR)
rhr4rir5rjr4rkr4r
rl)r�rr�r),r�r<rr �collectionsrvrZr>�textwrap�collections.abcrr�typingrrr�babelrr	�object�missingr
rre�VERBOSEr#r2r@rJr`rarp�OrderedDict�odict�tzinforq�UTC�LOCALTZ�
get_localzone�	STDOFFSET�	DSTOFFSET�DSTDIFFr�r�rrrr�<module>sF	
�
0�
 A