3
rޖY ( @ s d Z ddlZddlmZ ddlmZmZ ddlmZ dddd d
gZ da
ei Zdd Zd
d Z
dddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6'ZG d7d deZG d8d deZdefd9dZd:efd;d Zd?dZdS )Az
babel.core
~~~~~~~~~~
Core locale representation and locale data access.
:copyright: (c) 2013 by the Babel Team.
:license: BSD, see LICENSE for more details.
N)
localedata)picklestring_types)
PluralRuleUnknownLocaleErrorLocaledefault_localenegotiate_localeparse_localec C s t dd S )NzThe babel data files are not available. This usually happens because you are using a source checkout from Babel and you did not build the data files. Just make sure to run "python setup.py import_cldr" before installing the library.)RuntimeError r r /usr/lib/python3.6/core.py_raise_no_data_error s r c
C s\ t dkrPtj }tjj|d}tjj|s0t t|d}t j
|a W dQ R X t j| i S )a_ Return the dictionary for the given key in the global data.
The global data is stored in the ``babel/global.dat`` file and contains
information independent of individual locales.
>>> get_global('zone_aliases')['UTC']
u'Etc/GMT'
>>> get_global('zone_territories')['Europe/Berlin']
u'DE'
The keys available are:
- ``all_currencies``
- ``currency_fractions``
- ``language_aliases``
- ``likely_subtags``
- ``parent_exceptions``
- ``script_aliases``
- ``territory_aliases``
- ``territory_currencies``
- ``territory_languages``
- ``territory_zones``
- ``variant_aliases``
- ``windows_zone_mapping``
- ``zone_aliases``
- ``zone_territories``
.. note:: The internal structure of the data may change between versions.
.. versionadded:: 0.9
:param key: the data key
Nz
global.datrb)_global_datar Zget_base_dirospathjoinisfiler openr loadget)keydirnamefilenameZfileobjr r r
get_global# s #r Zar_SYZbg_BGZbs_BAZca_ESZcs_CZZda_DKZde_DEZel_GRZen_USZes_ESZet_EEZfa_IRZfi_FIZfr_FRZgl_ESZhe_ILZhu_HUZid_IDZis_ISZit_ITZja_JPZkm_KHZko_KRZlt_LTZlv_LVZmk_MKZnl_NLZnn_NOZnb_NOZpl_PLZpt_PTZro_ROZru_RUZsk_SKZsl_SIZsv_SEZth_THZtr_TRZuk_UA)'arZbgZbsZcaZcsZdaZdeZelenZesZetZfaZfifrZglZheZhuidisitZjaZkmZkoltZlvZmknlZnnnoZplZptZroZruZskZslZsvZthZtrZukc @ s e Zd ZdZdd ZdS )r z[Exception thrown when a locale is requested for which no locale data
is available.
c C s t j| d| || _dS )zjCreate the exception.
:param identifier: the identifier string of the unsupported locale
zunknown locale %rN) Exception__init__
identifier)selfr' r r r
r&