/usr/lib/python2.6/site-packages/babel
NameSizeModeActions
locale-data/-0755rm
localedata/-0755rm
localtime/-0755rm
messages/-0755rm
core.py311190644editdlrm
core.pyc325670644editdlrm
dates.py431110644editdlrm
dates.pyc424820644editdlrm
global.dat1096970644editdlrm
languages.py27480644editdlrm
languages.pyc32960644editdlrm
lists.py12710644editdlrm
lists.pyc14660644editdlrm
localedata.py62470644editdlrm
localedata.pyc75630644editdlrm
numbers.py232250644editdlrm
numbers.pyc223750644editdlrm
plural.py160210644editdlrm
plural.pyc201890644editdlrm
support.py218120644editdlrm
support.pyc255100644editdlrm
units.py110880644editdlrm
units.pyc92160644editdlrm
util.py81670644editdlrm
util.pyc108020644editdlrm
_compat.py11050644editdlrm
_compat.pyc24620644editdlrm
__init__.py7100644editdlrm
__init__.pyc9350644editdlrm
Edit: /usr/lib/python2.6/site-packages/babel/numbers.pyc (22375B)
Ñò zDVc @sêdZddklZlZddkZddkZddklZlZ ddk l Z l Z l Z ddklZe dƒZded„Zed „Zddeeed „Zed „Zed „Zed „Zed„Zed„Zed„Zded„Zded„Zded„Zded„Z de!fd„ƒYZ"ed„Z#ed„Z$dZ%dZ&de%Z'de&Z(dZ)ei*de'e(e)fƒZ+d„Z,d d!„Z-d"„Z.d#„Z/d$e0fd%„ƒYZ1dS(&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(tdatetdatetime(tdefault_localetLocalet get_global(t range_typet LC_NUMERICcCsiti|ƒ}|dj o:|i|ƒ}|id}||jo |||Sn|ii||ƒ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(RtparsetNonet plural_formt_datat currenciestget(tcurrencytcounttlocaletlocR t plural_names((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_currency_name!s    cCsti|ƒii||ƒ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 (RR tcurrency_symbolsR(RR((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_currency_symbol7s csqtdƒ}ˆdjotiƒ‰n!tˆtƒoˆiƒ‰nˆdjo ˆ‰n!tˆtƒoˆiƒ‰n|i|iƒdƒ}‡‡fd†}g} xº|D]²\} } } } | ot| Œ} n| ot| Œ} n| o|p| o|oU|| | ƒoE|o-| i h| d6| d6| d6| d6ƒqi| i | ƒq·q·W| S( s3Returns the list of currencies for the given territory that are valid for the given date range. In addition to that the currency database distinguishes between tender and non-tender currencies. By default only tender currencies are returned. The return value is a list of all currencies roughly ordered by the time of when the currency became active. The longer the currency is being in use the more to the left of the list it will be. The start date defaults to today. If no end date is given it will be the same as the start date. Otherwise a range can be defined. For instance this can be used to find the currencies in use in Austria between 1995 and 2011: >>> from datetime import date >>> get_territory_currencies('AT', date(1995, 1, 1), date(2011, 1, 1)) ['ATS', 'EUR'] Likewise it's also possible to find all the currencies in use on a single date: >>> get_territory_currencies('AT', date(1995, 1, 1)) ['ATS'] >>> get_territory_currencies('AT', date(2011, 1, 1)) ['EUR'] By default the return value only includes tender currencies. This however can be changed: >>> get_territory_currencies('US') ['USD'] >>> get_territory_currencies('US', tender=False, non_tender=True) ['USN', 'USS'] .. versionadded:: 2.0 :param territory: the name of the territory to find the currency fo :param start_date: the start date. If not given today is assumed. :param end_date: the end date. If not given the start date is assumed. :param tender: controls whether tender currencies should be included. :param non_tender: controls whether non-tender currencies should be included. :param include_details: if set to `True`, instead of returning currency codes the return value will be dictionaries with detail information. In that case each dictionary will have the keys ``'currency'``, ``'from'``, ``'to'``, and ``'tender'``. tterritory_currenciescs1|djp |ˆjo|djp |ˆjS(N(R (tstarttend(t start_datetend_date(s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt _is_activeƒsRtfromttottenderN(( RR tdate_ttodayt isinstancet datetime_RRtuppertappend(t territoryRRR t non_tendertinclude_detailsRtcursRtresultt currency_codeRRt is_tender((RRs,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_territory_currenciesCs83     cCsti|ƒiiddƒ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.(RR tnumber_symbolsR(R((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_decimal_symbolœscCsti|ƒiiddƒ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+(RR R0R(R((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_plus_sign_symbol§scCsti|ƒiiddƒ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-(RR R0R(R((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_minus_sign_symbol²scCsti|ƒiiddƒ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 t exponentialuE(RR R0R(R((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_exponential_symbol½scCsti|ƒiiddƒ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,(RR R0R(R((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytget_group_symbolÈscCst|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,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt format_numberÓs cCsHti|ƒ}|p|ii|ƒ}nt|ƒ}|i||ƒ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 (RR tdecimal_formatsRt parse_patterntapply(R;tformatRtpattern((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyR:ãs  cCsNti|ƒ}|p|ii|ƒ}nt|ƒ}|i||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(RR tcurrency_formatsRR>R?(R;RR@RRA((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytformat_currencys  cCsHti|ƒ}|p|ii|ƒ}nt|ƒ}|i||ƒ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 (RR tpercent_formatsRR>R?(R;R@RRA((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytformat_percent!s  cCsHti|ƒ}|p|ii|ƒ}nt|ƒ}|i||ƒ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 (RR tscientific_formatsRR>R?(R;R@RRA((s,/tmp/pip-build-lt8jXN/Babel/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,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyRHQscCsJy t|it|ƒdƒƒSWn#tj otd|ƒ‚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(tinttreplaceR9t ValueErrorRH(tstringR((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt parse_numberUs cCskti|ƒ}y2t|it|ƒdƒit|ƒdƒƒSWn#tj otd|ƒ‚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 RLt.s %r is not a valid decimal numberN(RR RRNR9R1RRH(RPR((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt parse_decimalos s [^0-9@#.,]s [0-9@#.,E+]s(?P(?:'[^']*'|%s)*)s(?P%s+)s(?P.*)s%s%s%sc Cs—t|tƒo|iƒ\}}}g}g}ttt|ƒƒ}x@t| ƒD]1}|o|i|iƒƒqT|idƒqTWx!t|ƒD]}|idƒq–Wx|o|i|iƒƒq°Wt |ƒdjo d}n|o|idƒndi t |ƒƒdi t |ƒƒfSd|i dƒ}d|jo3|i ddƒ\}} | djo d} qn|d}} || fS( s=Convert a number into a (intasstring, fractionasstring) tuplet0it-RLs%.9fRRi(RT(R#Rtas_tupletlisttmaptstrtrangeR&tpoptlentjointreversedtrstriptsplit( tvaluetsigntdigitstexptint_partt frac_parttittexttatb((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt split_number•s8  )   ic Cst|djƒodpd}t|ƒ}t|ƒ\}}||}d}t|ƒ|}|djp|t|ƒjon¡||djo d}n†||djo||ddjo d}nV||djoDxAt|dt|ƒƒD]"}||djo d}PqøqøWnd|} t|tƒo!tt|| |ƒƒ| |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ÿÿÿÿit5t13579RTi N(RMtabsRkR\RR#Rtfloat( RatndigitsRbRiRjRctaddRgtjtscale((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt bankersroundÅs,     &   !cCs‡t|ƒ}|idƒ}|djodS||d}|| d idƒ}|djo ||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è(R\trfind(tptwidthtg1tg2((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytparse_groupingîs    c CsÞt|tƒo|Sd„}d|joF|iddƒ\}}||ƒ\}}}||ƒ\}}}n&||ƒ\}}}d|}|}d|jo|iddƒ\}} nd } d|jo.d|jod|jotd ƒ‚qnd|jo|iddƒ\} } n |} d } d „} | | ƒ} | | ƒ}| o>| | | ƒ}| id ƒ}| id ƒ} | | ƒ}n d }d }t| ƒ}t|||f||f|| |||ƒS(sParse number format patternscSs:ti|ƒ}|djotd|ƒ‚n|iƒS(NsInvalid number pattern %r(t number_retsearchR ROtgroups(RAtrv((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt _match_number s t;iRUtEt@RRRTs5Significant digit patterns can not contain "@" or "0"RLcSszd}}xc|D][}|djo|d7}|d7}q|djo|d7}q|djoqqPqW||fS(s(Calculate the min and max allowed digitsis@0it#Ru((Rwtmintmaxtc((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytparse_precision&s     t+N( R#t NumberPatternR`R ROtrsplitt startswithtlstripR{(RAR€t neg_patternt pos_prefixR;t pos_suffixt neg_prefixt_t neg_suffixRdtintegertfractionRˆtint_prect frac_prectexp_plustexp_prectgrouping((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyR>sF           RŠcBsAeZd„Zd„Zdd„Zd„Zd„Zd„ZRS(c Cs¯||_||_||_||_||_||_||_||_ddi|i|iƒjo d|_ n7ddi|i|iƒjo d|_ n d|_ dS(Nt%RLidu‰ièi( RAtprefixtsuffixRšR–R—R™R˜R]Rs( tselfRARœRRšR–R—R™R˜((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt__init__Hs            cCsdt|ƒi|ifS(Ns<%s %r>(ttypeRIRA(Rž((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyt__repr__Ysc Cs¥t|tƒott|ƒƒ}n||i9}t|djƒ}|io t|ƒ}|o%tti ti |dƒƒƒ}nd}|i d|i djo||i dd8}n5|i do&t||i dƒ|i d}nt|tƒpt|ƒ}n|djo|d| }n|d|}d}|djot |ƒ}n|i ot|ƒ}nt|ƒ}d|i||id|idƒt|ƒ||it|ƒ|id|id|ƒf}n0d|ijo¨|it|ƒ|i d|i dƒ}d|joV|idƒ\} } |i| dd|ƒ} | ot|ƒ| } n| | }q|i|dd|ƒ}nxttt|ƒ|idƒƒ\} } | pd } |i| |i d|i d|ƒ} |i| |ƒ} | | }d |i|||i|f} d | joU| id t|||ƒƒ} | id |iƒƒ} | id t||ƒƒ} n| S(Nii iRLu%s%s%s%sRƒRRièRTu%s%s%su¤u¤¤¤u¤¤(R#RoRRYRsRMR™RntmathtfloortlogR–R5R˜R3t_format_sigdigR—R7t _format_intRAR`R1RkRtt _format_fracRœRRNRR%R( RžRaRRt is_negativeRdtexp_signR;RhRiRjtretval((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyR?\sp   %&            cCst|ƒ\}}t|ƒ}|djoC|djo6d}x-|idƒo|d}|d8}qAWntt|||ƒƒ\}}t||idƒƒ}|p d}nt|ƒ|jo|djo|S||jo|d||7}n|od||fS|S(s‡Convert value to a string. The resulting string will contain between (min, max) number of significant digits. RTRLiis%s.%s(RkR\RŒRtR(RžRaR…R†RiRjt ndecimalsRc((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyR¥œs&     c Csœt|ƒ}||jod|||}n|id}d}t|ƒ}xCt|ƒ|jo/||| |}|| }|id}qQW||S(NRTiRLi(R\RšR9( RžRaR…R†RRxtgsizetrettsymbol((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyR¦¶s     cCsÀ|i\}}t|ƒ|jo|d|t|ƒ7}n|djp |djot|ƒdjodSt|ƒ}x3t|ƒ|jo|ddjo|d }qWt|ƒ|S(NRTiRLiÿÿÿÿ(R—R\RMR1(RžRaRR…R†Rx((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyR§Ãs- $N( RIRJRŸR¡R R?R¥R¦R§(((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pyRŠFs    @  (2RKR/RRR¢treRRR!R$t babel.coreRRRt babel._compatRRR RRtTruetFalseR.R1R3R5R7R9R<R:RCRERGRORHRQRSt PREFIX_ENDt NUMBER_TOKENtPREFIX_PATTERNtNUMBER_PATTERNtSUFFIX_PATTERNtcompileR|RkRtR{R>tobjectRŠ(((s,/tmp/pip-build-lt8jXN/Babel/babel/numbers.pytsJ     W       0 )  B