ó ·ÑðQc@sÈdZddlZddlZddlmZddlmZiZejƒZ ej j ej j e ƒdƒZd„Zd„Zed„Zd „Zd efd „ƒYZd efd „ƒYZdS(sB 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. iÿÿÿÿN(tMutableMapping(tpicklet localedatacCs3|tkrtStjjtjjtd|ƒƒS(s²Check whether locale data is available for the given locale. Ther return value is `True` if it exists, `False` otherwise. :param name: the locale identifier string s%s.dat(t_cachetTruetostpathtexiststjoint_dirname(tname((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyRs cCs]ggtjtƒD]}tjj|ƒ^qD]*\}}|dkr/|dkr/|^q/S(s¦Return a list of all locale identifiers for which locale data is available. .. versionadded:: 0.8.1 :return: a list of locale identifiers (strings) s.dattroot(RtlistdirR Rtsplitext(tfilenametstemt extension((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pytlocale_identifiers&s8cCs%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 :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_locktacquireRtgettsplittlenRtloadtcopyRRR topentmergeRtclosetrelease(R tmerge_inheritedtdatatpartstparentRtfileobj((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyR3s*   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((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyRis"        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((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyt__init__‘scCsdt|ƒj|jfS(Ns<%s %r>(ttypet__name__R1(R2((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyt__repr__”scCsv|}x|jD]}||}qWt|tƒrE|j|ƒ}n-t|tƒrr|\}}|j|ƒ}n|S(sô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` (R1R&R(tresolveR)(R2R tbaseR,R/R0((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyR7—s  (R5t __module__t__doc__R3R6R7(((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyR(Šs  tLocaleDataDictcBsPeZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( sUDictionary wrapper that automatically resolves aliases to the actual values. cCs+||_|dkr|}n||_dS(N(t_dataR%R8(R2R R8((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyR3°s   cCs t|jƒS(N(RR<(R2((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyt__len__¶scCs t|jƒS(N(titerR<(R2((s:/usr/local/lib/python2.7/site-packages/babel/localedata.pyt__iter__¹scCsÂ|j|}}t|tƒr5|j|jƒ}nt|tƒrx|\}}|j|jƒjƒ}t||ƒnt|ƒt kr¢t |d|jƒ}n||k r¾||j| s   ! 6 !!