Viewing File: /usr/lib/python2.7/site-packages/babel/localedata.pyo

ó
dëðic@s6dZddlZddlZddlZddlZyddlZWnek
reddlZnXddlm	Z	dddgZ
dZiZej
ƒZejjejjeƒdƒZejd	ejƒZd
„Zd„Zd„Zed
„Zd„Zdefd„ƒYZde	efd„ƒYZ dS(s¬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.
iÿÿÿÿN(t	DictMixintexiststlisttloadsrestructuredtext ent
localedatas%^(con|prn|aux|nul|com[0-9]|lpt[0-9])$cCsjtjj|ƒ}tjdkrStjtjj|ƒdƒrStd|ƒ‚ntjj	t
d|ƒS(s?
    Resolve a locale identifier to a `.dat` path on disk.
    twin32isName %s is invalid on Windowss%s.dat(tostpathtbasenametsystplatformt_windows_reserved_name_retmatchtsplitextt
ValueErrortjoint_dirname(tname((s4/usr/lib/python2.7/site-packages/babel/localedata.pytresolve_locale_filename(s
cCs&|tkrtStjjt|ƒƒS(sÄCheck whether locale data is available for the given locale.

    :param name: the locale identifier string
    :return: `True` if the locale data exists, `False` otherwise
    :rtype: `bool`
    (t_cachetTrueRRRR(R((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR9scCs]ggtjtƒD]}tjj|ƒ^qD]*\}}|dkr/|dkr/|^q/S(sºReturn a list of all locale identifiers for which locale data is
    available.
    
    :return: a list of locale identifiers (strings)
    :rtype: `list`
    :since: version 0.8.1
    s.dattroot(RtlistdirRRR
(tfilenametstemt	extension((s4/usr/lib/python2.7/site-packages/babel/localedata.pyREs8cCstjƒzütj|ƒ}|s|dks5|r>i}nO|jdƒ}t|ƒdkrhd}ndj|d ƒ}t|ƒjƒ}t	|ƒ}t
|dƒ}zH|dkrÖ|rÖt|tj|ƒƒntj|ƒ}|t|<Wd|j
ƒXn|SWdtjƒXdS(s©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
    :return: the locale data
    :rtype: `dict`
    :raise `IOError`: if no locale data file is found for the given locale
                      identifer, or one of the locales it inherits from
    Rt_iiÿÿÿÿtrbN(t_cache_locktacquireRtgettsplittlenRRtcopyRtopentmergetpickletclosetrelease(Rtmerge_inheritedtdatatpartstparentRtfileobj((s4/usr/lib/python2.7/site-packages/babel/localedata.pyRRs*
		cCsðxé|jƒD]Û\}}|dk	r
|j|ƒ}t|tƒrÕ|dkrXi}nt|tƒrv||f}qÛt|tƒr¹|\}}|jƒ}t||ƒ||f}qÛ|jƒ}t||ƒn|}|||<q
q
WdS(s‹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'})
    >>> items = d.items(); items.sort(); 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(	titemstNoneRt
isinstancetdicttAliasttupleR!R#(tdict1tdict2tkeytval2tval1taliastothers((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR#Šs"	
R0cBs)eZdZd„Zd„Zd„ZRS(s£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`.
    cCst|ƒ|_dS(N(R1tkeys(tselfR9((s4/usr/lib/python2.7/site-packages/babel/localedata.pyt__init__²scCsdt|ƒj|jfS(Ns<%s %r>(ttypet__name__R9(R:((s4/usr/lib/python2.7/site-packages/babel/localedata.pyt__repr__µscCsv|}x|jD]}||}qWt|tƒrE|j|ƒ}n-t|tƒrr|\}}|j|ƒ}n|S(sResolve 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`
        (R9R.R0tresolveR1(R:R(tbaseR4R7R8((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR?¸s	(R=t
__module__t__doc__R;R>R?(((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR0«s		tLocaleDataDictcBs,eZdZdd„Zd„Zd„ZRS(sUDictionary wrapper that automatically resolves aliases to the actual
    values.
    cCs2tj||ƒ|dkr%|}n||_dS(N(R/R;R-R@(R:R(R@((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR;Ñs	cCsÄtj||ƒ}}t|tƒr:|j|jƒ}nt|tƒr}|\}}|j|jƒjƒ}t||ƒnt	|ƒtkr§t
|d|jƒ}n||k	rÀ|||<n|S(NR@(R/t__getitem__R.R0R?R@R1R!R#R<RC(R:R4torigtvalR7R8((s4/usr/lib/python2.7/site-packages/babel/localedata.pyRD×s
cCsttj|ƒd|jƒS(NR@(RCR/R!R@(R:((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR!åsN(R=RARBR-R;RDR!(((s4/usr/lib/python2.7/site-packages/babel/localedata.pyRCÌs	(!RBRR$treR	t	threadingtImportErrortdummy_threadingtUserDictRt__all__t
__docformat__RtRLockRRRtdirnamet__file__RtcompiletIRRRRRRR#tobjectR0R/RC(((s4/usr/lib/python2.7/site-packages/babel/localedata.pyt<module>s.
!			
8	!!
Back to Directory File Manager