509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ÌdaÁ  ã               @   sÜ   d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlZddl	m
Z
mZ dd„ Zi Zejƒ Zejjeƒ dƒZejd	ejƒZd
d„ Zdd„ Zdd„ Zdd„ Zddd„Zdd„ ZG dd„ deƒZG dd„ deƒZdS )aB  
    babel.localedata
    ~~~~~~~~~~~~~~~~

    Low-level locale data access.

    :note: The `Locale` class, which uses this module under the hood, provides a
           more convenient interface for accessing the locale data.

    :copyright: (c) 2013 by the Babel Team.
    :license: BSD, see LICENSE for more details.
é    N)ÚMutableMapping)Úchain)ÚpickleÚstring_typesc              C   s0   t tddƒr t tdd ƒr tj} ntjjtƒ} | S )NÚfrozenFÚ_MEIPASS)ÚgetattrÚsysr   ÚosÚpathÚdirnameÚ__file__)Zbasedir© r   ú /usr/lib/python3.6/localedata.pyÚget_base_dir   s    r   zlocale-dataz%^(con|prn|aux|nul|com[0-9]|lpt[0-9])$c             C   sP   |  st | tƒ rdS | jƒ jƒ } x(tjttƒ gƒD ]}| |jƒ kr4|S q4W dS )zŸNormalize a locale ID by stripping spaces and apply proper casing.

    Returns the normalized locale ID string or `None` if the ID is not
    recognized.
    N)Ú
isinstancer   ÚstripÚlowerr   Úfrom_iterableÚ_cacheÚlocale_identifiers)ÚnameZ	locale_idr   r   r   Únormalize_locale)   s    r   c             C   sJ   t jj| ƒ} tjdkr8tjt jj| ƒd ƒr8td|  ƒ‚t jj	t
d|  ƒS )z?
    Resolve a locale identifier to a `.dat` path on disk.
    Zwin32r   zName %s is invalid on Windowsz%s.dat)r
   r   Úbasenamer	   ÚplatformÚ_windows_reserved_name_reÚmatchÚsplitextÚ
ValueErrorÚjoinÚ_dirname)r   r   r   r   Úresolve_locale_filename7   s     r!   c             C   sF   |  st | tƒ rdS | tkr"dS tjjt| ƒƒ}|r:dS tt| ƒƒS )z¥Check whether locale data is available for the given locale.

    Returns `True` if it exists, `False` otherwise.

    :param name: the locale identifier string
    FT)	r   r   r   r
   r   Úexistsr!   Úboolr   )r   Z
file_foundr   r   r   r"   G   s    r"   c               C   s   dd„ dd„ t jtƒD ƒD ƒS )z¦Return a list of all locale identifiers for which locale data is
    available.

    .. versionadded:: 0.8.1

    :return: a list of locale identifiers (strings)
    c             S   s$   g | ]\}}|d kr|dkr|‘qS )z.datÚrootr   )Ú.0ZstemÚ	extensionr   r   r   ú
<listcomp>^   s    z&locale_identifiers.<locals>.<listcomp>c             S   s   g | ]}t jj|ƒ‘qS r   )r
   r   r   )r%   Úfilenamer   r   r   r'   _   s    )r
   Úlistdirr    r   r   r   r   r   V   s    r   Tc             C   sð   t jj| ƒ} tjƒ  zÌtj| ƒ}|sÞ| dks2| r8i }nXddlm} |dƒj| ƒ}|s„| j	dƒ}t
|ƒdkrrd}ndj|dd	… ƒ}t|ƒjƒ }t| ƒ}t|dƒ�.}| dkrÂ|rÂt|tj|ƒƒ n
tj|ƒ}W dQ R X |t| < |S tjƒ  X dS )
ae  Load the locale data for the given locale.

    The locale data is a dictionary that contains much of the data defined by
    the Common Locale Data Repository (CLDR). This data is stored as a
    collection of pickle files inside the ``babel`` package.

    >>> d = load('en_US')
    >>> d['languages']['sv']
    u'Swedish'

    Note that the results are cached, and subsequent requests for the same
    locale return the same dictionary:

    >>> d1 = load('en_US')
    >>> d2 = load('en_US')
    >>> d1 is d2
    True

    :param name: the locale identifier string (or "root")
    :param merge_inherited: whether the inherited data should be merged into
                            the data of the requested locale
    :raise `IOError`: if no locale data file is found for the given locale
                      identifer, or one of the locales it inherits from
    r$   r   )Ú
get_globalZparent_exceptionsÚ_é   NÚrbéÿÿÿÿ)r
   r   r   Ú_cache_lockÚacquirer   ÚgetZ
babel.corer*   ÚsplitÚlenr   ÚloadÚcopyr!   ÚopenÚmerger   Úrelease)r   Zmerge_inheritedÚdatar*   ÚparentÚpartsr(   Zfileobjr   r   r   r4   c   s.    

r4   c             C   s¤   xž|j ƒ D ]’\}}|dk	r
| j|ƒ}t|tƒr�|dkr:i }t|tƒrN||f}q”t|tƒr||\}}|jƒ }t||ƒ ||f}q”|jƒ }t||ƒ n|}|| |< q
W dS )an  Merge the data from `dict2` into the `dict1` dictionary, making copies
    of nested dictionaries.

    >>> d = {1: 'foo', 3: 'baz'}
    >>> merge(d, {1: 'Foo', 2: 'Bar'})
    >>> sorted(d.items())
    [(1, 'Foo'), (2, 'Bar'), (3, 'baz')]

    :param dict1: the dictionary to merge into
    :param dict2: the dictionary containing the data that should be merged
    N)Úitemsr1   r   ÚdictÚAliasÚtupler5   r7   )Zdict1Zdict2ÚkeyZval2Zval1ÚaliasÚothersr   r   r   r7   š   s"    






r7   c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r>   zŸRepresentation of an alias in the locale data.

    An alias is a value that refers to some other part of the locale data,
    as specified by the `keys`.
    c             C   s   t |ƒ| _d S )N)r?   Úkeys)ÚselfrC   r   r   r   Ú__init__Â   s    zAlias.__init__c             C   s   dt | ƒj| jf S )Nz<%s %r>)ÚtypeÚ__name__rC   )rD   r   r   r   Ú__repr__Å   s    zAlias.__repr__c             C   sR   |}x| j D ]}|| }qW t|tƒr2|j|ƒ}nt|tƒrN|\}}|j|ƒ}|S )zôResolve the alias based on the given data.

        This is done recursively, so if one alias resolves to a second alias,
        that second alias will also be resolved.

        :param data: the locale data
        :type data: `dict`
        )rC   r   r>   Úresolver?   )rD   r9   Úbaser@   rA   rB   r   r   r   rI   È   s    	


zAlias.resolveN)rG   Ú
__module__Ú__qualname__Ú__doc__rE   rH   rI   r   r   r   r   r>   »   s   r>   c               @   sJ   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d„ Z
dS )ÚLocaleDataDictzUDictionary wrapper that automatically resolves aliases to the actual
    values.
    Nc             C   s   || _ |d kr|}|| _d S )N)Ú_datarJ   )rD   r9   rJ   r   r   r   rE   á   s    zLocaleDataDict.__init__c             C   s
   t | jƒS )N)r3   rO   )rD   r   r   r   Ú__len__ç   s    zLocaleDataDict.__len__c             C   s
   t | jƒS )N)ÚiterrO   )rD   r   r   r   Ú__iter__ê   s    zLocaleDataDict.__iter__c             C   s€   | j |  }}t|tƒr$|j| jƒ}t|tƒrP|\}}|j| jƒjƒ }t||ƒ t|ƒt	krjt
|| jd�}||k	r||| j |< |S )N)rJ   )rO   r   r>   rI   rJ   r?   r5   r7   rF   r=   rN   )rD   r@   ZorigÚvalrA   rB   r   r   r   Ú__getitem__í   s    



zLocaleDataDict.__getitem__c             C   s   || j |< d S )N)rO   )rD   r@   Úvaluer   r   r   Ú__setitem__û   s    zLocaleDataDict.__setitem__c             C   s   | j |= d S )N)rO   )rD   r@   r   r   r   Ú__delitem__þ   s    zLocaleDataDict.__delitem__c             C   s   t | jjƒ | jd�S )N)rJ   )rN   rO   r5   rJ   )rD   r   r   r   r5     s    zLocaleDataDict.copy)N)rG   rK   rL   rM   rE   rP   rR   rT   rV   rW   r5   r   r   r   r   rN   Ü   s   
rN   )T)rM   r
   Úrer	   Z	threadingÚcollectionsr   Ú	itertoolsr   Zbabel._compatr   r   r   r   ÚRLockr/   r   r   r    ÚcompileÚIr   r   r!   r"   r   r4   r7   Úobjectr>   rN   r   r   r   r   Ú<module>   s*   	
7!!