509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
qDºY\"  ã               @   s  d 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m	Z	m
Z
 ddlZddlmZ eƒ Zdd„ ZejdejƒZd	d
„ ZejdƒZddd„Zdd„ ZG dd„ dejƒZddd„ZG dd„ deƒZG dd„ deƒZejZej Z ej!Z!ej"Z"ej#Z#ej$Z$ej%Z%dS )z©
    babel.util
    ~~~~~~~~~~

    Various utility classes and functions.

    :copyright: (c) 2013 by the Babel Team.
    :license: BSD, see LICENSE for more details.
é    N)Ú	timedeltaÚtzinfo)ÚizipÚimap)Ú	localtimec             c   s4   t ƒ }x(t| ƒD ]}||kr|V  |j|ƒ qW dS )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Úitem© r   ú/usr/lib/python3.6/util.pyÚdistinct   s
    r   s(   [ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c             C   sô   | j ƒ }| jdƒ zÐ| jƒ }|jtjƒ}|r>|ttjƒd… }tj|ƒ}|s–yddl	}|j
|jdƒƒ W n tttfk
r‚   Y nX | jƒ }tj|ƒ}|rÈ|rÄ|jdƒjdƒ}|dkrÄtdj|ƒƒ‚dS |rÜ|jdƒjdƒS dS W d| j|ƒ X dS )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   Nzlatin-1é   zutf-8zencoding problem: {0} with BOM)ÚtellÚseekÚreadlineÚ
startswithÚcodecsÚBOM_UTF8ÚlenÚPYTHON_MAGIC_COMMENT_reÚmatchÚparserZsuiteÚdecodeÚImportErrorÚSyntaxErrorÚUnicodeEncodeErrorÚgroupÚformat)ÚfpÚposZline1Zhas_bomÚmr   Zline2Zmagic_comment_encodingr   r   r   Úparse_encoding0   s8    


r$   z'from\s+__future__\s+import\s+\(*(.+)\)*úlatin-1c       
      C   sÂ   ddl }| jƒ }| jdƒ d}z’| jƒ j|ƒ}tjdd|ƒ}tjdd|ƒ}tjdd|ƒ}xTtj|ƒD ]F}d	d
„ |j	dƒj
dƒD ƒ}x&|D ]}t||dƒ}	|	rˆ||	jO }qˆW qdW W d| j|ƒ X |S )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]+ú c             S   s   g | ]}|j ƒ j d ƒ‘qS )z())Ústrip)Ú.0Úxr   r   r   ú
<listcomp>|   s    z&parse_future_flags.<locals>.<listcomp>r   ú,)Ú
__future__r   r   Úreadr   ÚreÚsubÚPYTHON_FUTURE_IMPORT_reÚfinditerr   ÚsplitÚgetattrZcompiler_flag)
r!   Úencodingr,   r"   ÚflagsZbodyr#   ÚnamesÚnameZfeaturer   r   r   Úparse_future_flagsf   s"    

r8   c             C   sˆ   dddddddœ}g }xHt tjd| ƒƒD ]4\}}|d	 rH|j|| ƒ q(|r(|jtj|ƒƒ q(W tjd
j|ƒd |jtj	dƒƒ}|dk	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('**/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**z	([?*]+/?)é   Ú ú$ú/N)
Ú	enumerater.   r2   ÚappendÚescaper   ÚjoinÚreplaceÚosÚsep)ÚpatternÚfilenameZsymbolsZbufÚidxÚpartr   r   r   r   Ú	pathmatch†   s     rJ   c               @   s   e Zd ZejdƒZdS )ÚTextWrapperz((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))N)Ú__name__Ú
__module__Ú__qualname__r.   ÚcompileZ
wordsep_rer   r   r   r   rK   ´   s   rK   éF   r<   c             C   s   t |||d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_indentZbreak_long_words)rK   Zwrap)ÚtextrQ   rR   rS   Úwrapperr   r   r   Úwraptext»   s    rV   c               @   s”   e Zd ZdZd!dd„Zdd„ Zdd„ Zd	d
„ ZeZdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zefdd„Zdd„ Zd"dd„Zdd„ Zdd„ Zdd „ ZdS )#ÚodictzkOrdered dict implementation.

    :see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
    Nc             C   s$   t j| |pi ƒ tt j| ƒƒ| _d S )N)ÚdictÚ__init__ÚlistÚkeysÚ_keys)ÚselfÚdatar   r   r   rY   Ò   s    zodict.__init__c             C   s   t j| |ƒ | jj|ƒ d S )N)rX   Ú__delitem__r\   Úremove)r]   Úkeyr   r   r   r_   Ö   s    zodict.__delitem__c             C   s*   || k}t j| ||ƒ |r&| jj|ƒ d S )N)rX   Ú__setitem__r\   r@   )r]   ra   r   Znew_keyr   r   r   rb   Ú   s    zodict.__setitem__c             C   s
   t | jƒS )N)r   r\   )r]   r   r   r   Ú__iter__à   s    zodict.__iter__c             C   s   t j| ƒ g | _d S )N)rX   Úclearr\   )r]   r   r   r   rd   ä   s    
zodict.clearc             C   s   t ƒ }|j| ƒ |S )N)rW   Úupdate)r]   Údr   r   r   Úcopyè   s    
z
odict.copyc             C   s   t | j| jƒ ƒS )N)Úzipr\   Úvalues)r]   r   r   r   Úitemsí   s    zodict.itemsc             C   s   t | j| jƒ ƒS )N)r   r\   Ú
itervalues)r]   r   r   r   Ú	iteritemsð   s    zodict.iteritemsc             C   s   | j d d … S )N)r\   )r]   r   r   r   r[   ó   s    z
odict.keysc             C   sV   yt j| |ƒ}| jj|ƒ |S  tk
rP } z|tkr<|‚n|S W Y d d }~X nX d S )N)rX   Úpopr\   r`   ÚKeyErrorÚmissing)r]   ra   ÚdefaultÚvalueÚer   r   r   rm   ö   s    z	odict.popc             C   s   | j j|ƒ tj|ƒS )N)r\   r`   rX   Úpopitem)r]   ra   r   r   r   rs     s    zodict.popitemc             C   s(   t j| ||ƒ || jkr$| jj|ƒ d S )N)rX   Ú
setdefaultr\   r@   )r]   ra   Zfailobjr   r   r   rt     s    
zodict.setdefaultc             C   s"   x|j ƒ D ]\}}|| |< q
W d S )N)rj   )r]   rX   ra   Úvalr   r   r   re   
  s    zodict.updatec             C   s   t | j| jƒS )N)ÚmapÚgetr\   )r]   r   r   r   ri     s    zodict.valuesc             C   s   t | j| jƒS )N)r   rw   r\   )r]   r   r   r   rk     s    zodict.itervalues)N)N)rL   rM   rN   Ú__doc__rY   r_   rb   rc   Ziterkeysrd   rg   rj   rl   r[   ro   rm   rs   rt   re   ri   rk   r   r   r   r   rW   Ì   s"   

rW   c               @   sB   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	dS )ÚFixedOffsetTimezonez&Fixed offset in minutes east from UTC.Nc             C   s&   t |d�| _|d krd| }|| _d S )N)Zminutesz
Etc/GMT%+d)r   Ú_offsetÚzone)r]   Úoffsetr7   r   r   r   rY     s    zFixedOffsetTimezone.__init__c             C   s   | j S )N)r{   )r]   r   r   r   Ú__str__  s    zFixedOffsetTimezone.__str__c             C   s   d| j | jf S )Nz<FixedOffset "%s" %s>)r{   rz   )r]   r   r   r   Ú__repr__!  s    zFixedOffsetTimezone.__repr__c             C   s   | j S )N)rz   )r]   Údtr   r   r   Ú	utcoffset$  s    zFixedOffsetTimezone.utcoffsetc             C   s   | j S )N)r{   )r]   r   r   r   r   Útzname'  s    zFixedOffsetTimezone.tznamec             C   s   t S )N)ÚZERO)r]   r   r   r   r   Údst*  s    zFixedOffsetTimezone.dst)N)
rL   rM   rN   rx   rY   r}   r~   r€   r�   rƒ   r   r   r   r   ry     s   
ry   )r%   )rP   r<   r<   )&rx   r   Zdatetimer   r   rD   r.   ÚtextwrapZbabel._compatr   r   ZpytzZ_pytzZbabelr   Úobjectro   r   rO   ÚVERBOSEr   r$   r0   r8   rJ   rK   rV   rX   rW   ry   ZutcZUTCZLOCALTZZget_localzoneZ	STDOFFSETZ	DSTOFFSETZDSTDIFFr‚   r   r   r   r   Ú<module>
   s8   
2
 .
I