/usr/lib/python3/dist-packages/babel/__pycache__
Edit: /usr/lib/python3/dist-packages/babel/__pycache__/numbers.cpython-310.pyc (30964B)
o
l:^ @ s& d Z ddlZddlmZmZ ddlZddlmZm Z m
Z
ddlmZm
Z
ze W n ey3 eZY nw edZG dd deZdLd d
ZdLddZdLd
dZdLddZdefddZefddZdd ZdefddZ dMddZefddZefdd Zefd!d"Zefd#d$Z efd%d&Z!efd'd(Z"d)d* Z#d+d, Z$dedfd-d.Z%G d/d0 d0e&Z'dedd1dfd2d3Z(dedd1dfd4d5Z)dedfd6d7Z*dedfd8d9Z+G d:d; d;e,Z-efd
d?Z/d@Z0dAZ1dBe0 Z2dCe1 Z3dDZ4e5dEe2e3e4f Z6dFdG Z7dHdI Z8G dJdK dKe9Z:dS )Na
babel.numbers
~~~~~~~~~~~~~
Locale dependent formatting and parsing of numeric data.
The default locale for the functions in this module is determined by the
following environment variables, in that order:
* ``LC_NUMERIC``,
* ``LC_ALL``, and
* ``LANG``
:copyright: (c) 2013-2019 by the Babel Team.
:license: BSD, see LICENSE for more details.
N)datedatetime)default_localeLocale
get_global)decimalstring_types
LC_NUMERICc @ s e Zd ZdZdd ZdS )UnknownCurrencyErrorzRException thrown when a currency is requested for which no data is available.
c C s t | d| || _dS )zkCreate the exception.
:param identifier: the identifier string of the unsupported currency
zUnknown currency %r.N) Exception__init__
identifier)selfr
r //usr/lib/python3/dist-packages/babel/numbers.pyr + s
zUnknownCurrencyError.__init__N)__name__
__module____qualname____doc__r r r r r r
' s r
c C s, | rt | j }t|S td}t|S )aM Return a `set` of normalized currency codes.
.. versionadded:: 2.5.0
:param locale: filters returned currency codes by the provided locale.
Expected to be a locale instance or code. If no locale is
provided, returns the list of all currencies from all
locales.
all_currencies)r parse
currencieskeysr set)localer r r r list_currencies5 s
r c C s | t |vr
t| dS )a Check the currency code is recognized by Babel.
Accepts a ``locale`` parameter for fined-grained validation, working as
the one defined above in ``list_currencies()`` method.
Raises a `UnknownCurrencyError` exception if the currency is unknown to Babel.
N)r r
currencyr r r r validate_currencyG s r c C s8 | rt | ts dS zt| | W dS ty Y dS w )zy Returns `True` only if a currency is recognized by Babel.
This method always return a Boolean and never raise.
FT)
isinstancer r r
r r r r is_currencyS s r c C s$ t | tr | } t| |sdS | S )zReturns the normalized sting of any currency code.
Accepts a ``locale`` parameter for fined-grained validation, working as
the one defined above in ``list_currencies()`` method.
Returns None if the currency is unknown to Babel.
N)r r upperr r r r r normalize_currencya s
r" c C sH t |}|dur||}|jd }| |v r|| | S |j| | S )a Return the name used by the locale for the specified currency.
>>> get_currency_name('USD', locale='en_US')
u'US Dollar'
.. versionadded:: 0.9.4
:param currency: the currency code.
:param count: the optional count. If provided the currency name
will be pluralized to that number if possible.
:param locale: the `Locale` object or locale identifier.
Ncurrency_names_plural)r r plural_form_datar get)r countr locr$ plural_namesr r r get_currency_namep s
r* c C s t |j| | S )zReturn the symbol used by the locale for the specified currency.
>>> get_currency_symbol('USD', locale='en_US')
u'$'
:param currency: the currency code.
:param locale: the `Locale` object or locale identifier.
)r r currency_symbolsr&