ó ™‚Mc@sdZddlZddlZyddlZWnek rMddlZnXddlmZdddgZdZ iZ ej ƒZ ej jej jeƒdƒZd „Zd „Zed „Zd „Zd efd„ƒYZdeefd„ƒYZdS(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 localedatacCs3|tkrtStjjtjjtd|ƒƒ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` s%s.dat(t_cachetTruetostpathRtjoint_dirname(tname((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR$s 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(RtlistdirR Rtsplitext(tfilenametstemt extension((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR0s8cCs%tjƒz tj|ƒ}|s|dks5| r>i}nO|jdƒ}t|ƒdkrhd}ndj|d ƒ}t|ƒjƒ}t j jt d|ƒ}t |dƒ}zH|dkrã|rãt |tj|ƒƒntj|ƒ}|t|>> 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 R t_iiÿÿÿÿs%s.dattrbN(t _cache_locktacquireRtgettsplittlenR RtcopyRRR topentmergetpickletclosetrelease(R tmerge_inheritedtdatatpartstparentRtfileobj((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR=s*   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|}|||>> 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 isinstancetdicttAliasttupleRR(tdict1tdict2tkeytval2tval1taliastothers((s4/usr/lib/python2.7/site-packages/babel/localedata.pyRus"        R(cBs)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(R)tkeys(tselfR1((s4/usr/lib/python2.7/site-packages/babel/localedata.pyt__init__scCsdt|ƒj|jfS(Ns<%s %r>(ttypet__name__R1(R2((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` (R1R&R(tresolveR)(R2R tbaseR,R/R0((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR7£s  (R5t __module__t__doc__R3R6R7(((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR(–s  tLocaleDataDictcBs,eZdZdd„Zd„Zd„ZRS(sUDictionary wrapper that automatically resolves aliases to the actual values. cCs2tj||ƒ|dkr%|}n||_dS(N(R'R3R%R8(R2R R8((s4/usr/lib/python2.7/site-packages/babel/localedata.pyR3¼s  cCsÄtj||ƒ}}t|tƒr:|j|jƒ}nt|tƒr}|\}}|j|jƒjƒ}t||ƒnt |ƒtkr§t |d|jƒ}n||k rÀ|||s$    ! 8 !!