%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/babel/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyo

�
��Qc@s�dZddlmZmZddlZddlZddlmZmZddl	m
Z
ed�Zded�Z
ed�Zed	�Zed
�Zed�Zed�Zed
�Zed�Zded�Zded�Zded�Zded�Zdefd��YZed�Zed�ZdZdZdeZdeZ dZ!ej"dee e!f�Z#d�Z$dd�Z%d �Z&d!�Z'd"e(fd#��YZ)dS($s�
    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 by the Babel Team.
    :license: BSD, see LICENSE for more details.
i����(tDecimaltInvalidOperationN(tdefault_localetLocale(t
range_typet
LC_NUMERICcCsetj|�}|dk	rR|j|�}|jd}||krR|||Sn|jj||�S(s�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
    tcurrency_names_pluralN(RtparsetNonetplural_formt_datat
currenciestget(tcurrencytcounttlocaletlocR	tplural_names((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytget_currency_name s

cCstj|�jj||�S(s�Return 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
    (RRtcurrency_symbolsR(R
R((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytget_currency_symbol6s	cCstj|�jjdd�S(s�Return the symbol used by the locale to separate decimal fractions.

    >>> get_decimal_symbol('en_US')
    u'.'

    :param locale: the `Locale` object or locale identifier
    tdecimalu.(RRtnumber_symbolsR(R((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytget_decimal_symbolBscCstj|�jjdd�S(s�Return the plus sign symbol used by the current locale.

    >>> get_plus_sign_symbol('en_US')
    u'+'

    :param locale: the `Locale` object or locale identifier
    tplusSignu+(RRRR(R((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytget_plus_sign_symbolMscCstj|�jjdd�S(s�Return the plus sign symbol used by the current locale.

    >>> get_minus_sign_symbol('en_US')
    u'-'

    :param locale: the `Locale` object or locale identifier
    t	minusSignu-(RRRR(R((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytget_minus_sign_symbolXscCstj|�jjdd�S(s�Return the symbol used by the locale to separate mantissa and exponent.

    >>> get_exponential_symbol('en_US')
    u'E'

    :param locale: the `Locale` object or locale identifier
    texponentialuE(RRRR(R((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytget_exponential_symbolcscCstj|�jjdd�S(s�Return the symbol used by the locale to separate groups of thousands.

    >>> get_group_symbol('en_US')
    u','

    :param locale: the `Locale` object or locale identifier
    tgroupu,(RRRR(R((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytget_group_symbolnscCst|d|�S(uReturn the given number formatted for a specific locale.

    >>> format_number(1099, locale='en_US')
    u'1,099'
    >>> format_number(1099, locale='de_DE')
    u'1.099'


    :param number: the number to format
    :param locale: the `Locale` object or locale identifier
    R(tformat_decimal(tnumberR((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyt
format_numberys
cCsFtj|�}|s*|jj|�}nt|�}|j||�S(u�Return the given decimal number formatted for a specific locale.

    >>> format_decimal(1.2345, locale='en_US')
    u'1.234'
    >>> format_decimal(1.2346, locale='en_US')
    u'1.235'
    >>> format_decimal(-1.2346, locale='en_US')
    u'-1.235'
    >>> format_decimal(1.2345, locale='sv_SE')
    u'1,234'
    >>> format_decimal(1.2345, locale='de')
    u'1,234'

    The appropriate thousands grouping and the decimal separator are used for
    each locale:

    >>> format_decimal(12345.5, locale='en_US')
    u'12,345.5'

    :param number: the number to format
    :param format:
    :param locale: the `Locale` object or locale identifier
    (RRtdecimal_formatsRt
parse_patterntapply(R!tformatRtpattern((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyR �s
cCsLtj|�}|s*|jj|�}nt|�}|j||d|�S(u\Return formatted currency value.

    >>> format_currency(1099.98, 'USD', locale='en_US')
    u'$1,099.98'
    >>> format_currency(1099.98, 'USD', locale='es_CO')
    u'1.099,98\xa0US$'
    >>> format_currency(1099.98, 'EUR', locale='de_DE')
    u'1.099,98\xa0\u20ac'

    The pattern can also be specified explicitly.  The currency is
    placed with the '¤' sign.  As the sign gets repeated the format
    expands (¤ being the symbol, ¤¤ is the currency abbreviation and
    ¤¤¤ is the full name of the currency):

    >>> format_currency(1099.98, 'EUR', u'¤¤ #,##0.00', locale='en_US')
    u'EUR 1,099.98'
    >>> format_currency(1099.98, 'EUR', u'#,##0.00 ¤¤¤', locale='en_US')
    u'1,099.98 euros'

    :param number: the number to format
    :param currency: the currency code
    :param locale: the `Locale` object or locale identifier
    R
(RRtcurrency_formatsRR$R%(R!R
R&RR'((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytformat_currency�s
cCsFtj|�}|s*|jj|�}nt|�}|j||�S(sReturn formatted percent value for a specific locale.

    >>> format_percent(0.34, locale='en_US')
    u'34%'
    >>> format_percent(25.1234, locale='en_US')
    u'2,512%'
    >>> format_percent(25.1234, locale='sv_SE')
    u'2\xa0512\xa0%'

    The format pattern can also be specified explicitly:

    >>> format_percent(25.1234, u'#,##0\u2030', locale='en_US')
    u'25,123\u2030'

    :param number: the percent number to format
    :param format:
    :param locale: the `Locale` object or locale identifier
    (RRtpercent_formatsRR$R%(R!R&RR'((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytformat_percent�s
cCsFtj|�}|s*|jj|�}nt|�}|j||�S(s�Return value formatted in scientific notation for a specific locale.

    >>> format_scientific(10000, locale='en_US')
    u'1E4'

    The format pattern can also be specified explicitly:

    >>> format_scientific(1234567, u'##0E00', locale='en_US')
    u'1.23E06'

    :param number: the number to format
    :param format:
    :param locale: the `Locale` object or locale identifier
    (RRtscientific_formatsRR$R%(R!R&RR'((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytformat_scientific�s
tNumberFormatErrorcBseZdZRS(s>Exception raised when a string cannot be parsed into a number.(t__name__t
__module__t__doc__(((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyR.�scCsHy t|jt|�d��SWn!tk
rCtd|��nXdS(sSParse localized number string into an integer.

    >>> parse_number('1,099', locale='en_US')
    1099
    >>> parse_number('1.099', locale='de_DE')
    1099

    When the given string cannot be parsed, an exception is raised:

    >>> parse_number('1.099,98', locale='de')
    Traceback (most recent call last):
        ...
    NumberFormatError: '1.099,98' is not a valid number

    :param string: the string to parse
    :param locale: the `Locale` object or locale identifier
    :return: the parsed number
    :raise `NumberFormatError`: if the string can not be converted to a number
    ts%r is not a valid numberN(tinttreplaceRt
ValueErrorR.(tstringR((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytparse_number�s 
cCsitj|�}y2t|jt|�d�jt|�d��SWn!tk
rdtd|��nXdS(s�Parse localized decimal string into a decimal.

    >>> parse_decimal('1,099.98', locale='en_US')
    Decimal('1099.98')
    >>> parse_decimal('1.099,98', locale='de')
    Decimal('1099.98')

    When the given string cannot be parsed, an exception is raised:

    >>> parse_decimal('2,109,998', locale='de')
    Traceback (most recent call last):
        ...
    NumberFormatError: '2,109,998' is not a valid decimal number

    :param string: the string to parse
    :param locale: the `Locale` object or locale identifier
    :raise NumberFormatError: if the string can not be converted to a
                              decimal number
    R2t.s %r is not a valid decimal numberN(RRRR4RRRR.(R6R((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyt
parse_decimals
s
[^0-9@#.,]s
[0-9@#.\-,E+]s(?P<prefix>(?:'[^']*'|%s)*)s(?P<number>%s+)s(?P<suffix>.*)s%s%s%sc
Cs�t|t�r#|j�\}}}g}g}ttt|��}x>t|�D]/}|ru|j|j��qS|jd�qSWx!t|�D]}|jd�q�Wx|r�|j|j��q�Wt	|�dkr�d}n|r�|jd�ndj
t|��dj
t|��fSd|jd�}d|krr|j
dd�\}}	|	dkrd}	qn
|d}}	||	fS(	s=Convert a number into a (intasstring, fractionasstring) tuplet0it-R2s%.9fR8i(R:(t
isinstanceRtas_tupletlisttmaptstrtrangetappendtpoptlentjointreversedtrstriptsplit(
tvaluetsigntdigitstexptint_partt	frac_parttittexttatb((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytsplit_number;s2		(
ic
Csqt|dk�rdpd}t|�}t|�\}}||}d}t|�|}|dks|t|�kr}n�||dkr�d}n~||dkr�||ddkr�d}nQ||dkrx>t|dt|��D] }||dkr�d}Pq�q�Wnd|}	t|t�rMtt||	|��|	|Stt||	|��|	|SdS(	sCRound a number to a given precision.

    Works like round() except that the round-half-even (banker's rounding)
    algorithm is used instead of round-half-up.

    >>> bankersround(5.5, 0)
    6.0
    >>> bankersround(6.5, 0)
    6.0
    >>> bankersround(-6.5, 0)
    -6.0
    >>> bankersround(1234.0, -2)
    1200.0
    ii����it5t13579R:i
N(R3tabsRSRDRR<Rtfloat(
RItndigitsRJRQRRRKtaddROtjtscale((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytbankersroundks*
	$	 
 cCs�t|�}|jd�}|dkr+dS||d}||d jd�}|dkrg||fS|||d}||fS(s�Parse primary and secondary digit grouping

    >>> parse_grouping('##')
    (1000, 1000)
    >>> parse_grouping('#,###')
    (3, 3)
    >>> parse_grouping('#,####,###')
    (3, 4)
    t,i����i�ii(i�i�(RDtrfind(tptwidthtg1tg2((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytparse_grouping�s

c
Cs�t|t�r|Sd�}d|krm|jdd�\}}||�\}}}||�\}}}n%||�\}}}d|}|}d|kr�|jdd�\}}	nd
}	d|kr�d|kr�d|kr�td	��q�nd|kr|jdd�\}
}n|}
d
}d�}||
�}
||�}|	r�||
|�}|	jd�}|	jd�}	||	�}nd
}d
}t|
�}t|||f||f||
|||�S(sParse number format patternscSs8tj|�}|dkr.td|��n|j�S(NsInvalid number pattern %r(t	number_retsearchRR5tgroups(R'trv((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyt
_match_number�st;iR;tEt@R8R:s5Significant digit patterns can not contain "@" or "0"R2cSstd}}x]|D]U}|dkr:|d7}|d7}q|dkrS|d7}q|dkreqqPqW||fS(s(Calculate the min and max allowed digitsis@0it#R]((R_tmintmaxtc((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pytparse_precision�s




t+N(	R<t
NumberPatternRHRR5trsplitt
startswithtlstripRc(R'Rhtneg_patternt
pos_prefixR!t
pos_suffixt
neg_prefixt_t
neg_suffixRLtintegertfractionRptint_prect	frac_prectexp_plustexp_prectgrouping((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyR$�sF	
	RrcBsAeZd�Zd�Zdd�Zd�Zd�Zd�ZRS(c		Cs�||_||_||_||_||_||_||_||_ddj|j|j�krsd|_	n4ddj|j|j�kr�d|_	n	d|_	dS(Nt%R2idu‰i�i(
R'tprefixtsuffixR�R~RR�R�RER[(	tselfR'R�R�R�R~RR�R�((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyt__init__�s								cCsdt|�j|jfS(Ns<%s %r>(ttypeR/R'(R�((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyt__repr__�sc	Cs�t|t�r$tt|��}n||j9}t|dk�}|jr�t|�}|r�ttj	tj
|d���}nd}|jd|jdkr�||jdd8}n2|jdr�t||jd�|jd}nt|t�s
t|�}n|dkr(|d|}n|d|}d}|dkrWt|�}n|j
rot|�}nt|�}d|j||jd|jd�t|�||jt|�|jd|jd|�f}n(d|jkr�|jt|�|jd|jd�}d|krt|jd�\}	}
|j|	dd|�}	|
rgt|�|
}
n|	|
}q|j|dd|�}nvttt|�|jd��\}	}
|
p�d	}
|j|	|jd|jd|�}	|j|
|�}
|	|
}d
|j|||j|f}d|kr�|jdt|||��}|jd
|j��}|jdt||��}n|S(Nii
iR2u%s%s%s%sRkR8i�R:u%s%s%su¤u¤¤¤u¤¤(R<RWRR@R[R3R�RVtmathtfloortlogR~RR�Rt_format_sigdigRRt_format_intR'RHRRSR\t_format_fracR�R�R4RtupperR(R�RIRR
tis_negativeRLtexp_signR!RPRQRRtretval((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyR%sp
	$
%	



	cCst|�\}}t|�}|dkri|dkrid}x*|jd�re|d}|d8}q?Wntt|||��\}}t||jd��}|s�d}nt|�|kr�|dkr�|S||kr�|d||7}n|rd||fS|S(s�Convert value to a string.

        The resulting string will contain between (min, max) number of
        significant digits.
        R:R2iis%s.%s(RSRDRtR\Ru(R�RIRmRnRQRRt	ndecimalsRK((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyR�Bs$
	c	Cs�t|�}||kr-d|||}n|jd}d}t|�}xAt|�|kr�||||}|| }|jd}qOW||S(NR:iR2i(RDR�R(	R�RIRmRnRR`tgsizetrettsymbol((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyR�\s
cCs�|j\}}t|�|kr<|d|t|�7}n|dksf|dkrjt|�dkrjdSt|�}x0t|�|kr�|ddkr�|d }qyWt|�|S(NR:iR2i����(RRDR3R(R�RIRRmRnR`((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyR�is*%N(	R/R0R�R�RR%R�R�R�(((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyRr�s		@		
(*R1RRRR�tret
babel.coreRRt
babel._compatRRRRRRRRRRR"R R)R+R-R5R.R7R9t
PREFIX_ENDtNUMBER_TOKENtPREFIX_PATTERNtNUMBER_PATTERNtSUFFIX_PATTERNtcompileRdRSR\RcR$tobjectRr(((s>/opt/alt/python27/lib/python2.7/site-packages/babel/numbers.pyt<module>sB


	0)		B

Zerion Mini Shell 1.0