3
da @ s d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlZddl m
Z
mZ dd Zi Z
ej Zejje dZejd ejZd
d Zdd
Zdd Zdd ZdddZdd ZG dd deZG dd deZdS )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)picklestring_typesc C s0 t tddr t tdd r tj} ntjjt} | S )NfrozenF_MEIPASS)getattrsysr ospathdirname__file__)Zbasedir r /usr/lib/python3.6/localedata.pyget_base_dir s r zlocale-dataz%^(con|prn|aux|nul|com[0-9]|lpt[0-9])$c C sP | st | t rdS | j j } x(tjtt gD ]}| |j kr4|S q4W dS )zNormalize 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 striplowerr
from_iterable_cachelocale_identifiers)nameZ locale_idr r r normalize_locale) s r c C sJ t jj| } tjdkr8tjt jj| d r8td| t jj t
d| S )z?
Resolve a locale identifier to a `.dat` path on disk.
Zwin32r zName %s is invalid on Windowsz%s.dat)r
r basenamer platform_windows_reserved_name_rematchsplitext
ValueErrorjoin_dirname)r r r r resolve_locale_filename7 s r! c C sF | st | t rdS | tkr"dS tjjt| }|r:dS tt| S )zCheck 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 dd dd t jtD D S )zReturn 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 kr|dkr|qS )z.datrootr ).0Zstem extensionr r r