ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ qDYc@sDdZddlZddlmZmZddlmZddlm Z m Z m Z ddl m Z mZddlmZe dZd efd YZdd Zdd Zdd ZddZdedZedZdZddeeedZedZedZ edZ!edZ"edZ#edZ$dedZ%de&fdYZ'deeddZ(dedZ)dedZ*d e+fd!YZ,ed"Z-ed#Z.d$Z/d%Z0d&e/Z1d'e0Z2d(Z3ej4d)e1e2e3fZ5d*Z6d+Z7d,e8fd-YZ9dS(.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. iN(tdatetdatetime(tchain(tdefault_localetLocalet get_global(tdecimalt string_types(tlocale_identifierst LC_NUMERICtUnknownCurrencyErrorcBseZdZdZRS(sRException thrown when a currency is requested for which no data is available. cCs!tj|d|||_dS(skCreate the exception. :param identifier: the identifier string of the unsupported currency sUnknown currency %r.N(t Exceptiont__init__t identifier(tselfR ((s1/usr/lib/python2.7/site-packages/babel/numbers.pyR %s(t__name__t __module__t__doc__R (((s1/usr/lib/python2.7/site-packages/babel/numbers.pyR !scCs7|r!tj|jj}n td}t|S(sM 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. tall_currencies(Rtparset currenciestkeysRtset(tlocaleR((s1/usr/lib/python2.7/site-packages/babel/numbers.pytlist_currencies/s  cCs%|t|kr!t|ndS(s 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(RR (tcurrencyR((s1/usr/lib/python2.7/site-packages/babel/numbers.pytvalidate_currencyAscCsE| st|t rtSyt||Wntk r@tSXtS(sy Returns `True` only if a currency is recognized by Babel. This method always return a Boolean and never raise. (t isinstanceRtFalseRR tTrue(RR((s1/usr/lib/python2.7/site-packages/babel/numbers.pyt is_currencyMs cCs5t|tr|j}nt||s1dS|S(sReturns 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(RRtupperR(RR((s1/usr/lib/python2.7/site-packages/babel/numbers.pytnormalize_currency[s cCsetj|}|dk rR|j|}|jd}||krR|||Sn|jj||S(sReturn 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(RRtNonet plural_formt_dataRtget(RtcountRtlocR#t plural_names((s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_currency_namejs    cCstj|jj||S(sReturn 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%(RR((s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_currency_symbols cCs$td}|j||ddS(sReturn currency's precision. Precision is the number of decimals found after the decimal point in the currency's format pattern. .. versionadded:: 2.5.0 :param currency: the currency code. tcurrency_fractionstDEFAULTi(RR%(Rt precisions((s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_currency_precisions cs]td}dkr'tjnttrEjndkrZnttrxjn|j|jd}fd}g} x|D]\} } } } | rt| } n| rt| } n| r|s| r|r|| | r|rE| j i| d6| d6| d6| d6qU| j | qqW| S( ssReturns 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, ... start_date=date(2014, 1, 1)) ['USN', 'USS'] .. versionadded:: 2.0 :param territory: the name of the territory to find the currency for. :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_currenciescs.|dks|ko-|dkp-|kS(N(R"(tstarttend(tend_datet start_date(s1/usr/lib/python2.7/site-packages/babel/numbers.pyt _is_activesRtfromttottenderN(( RR"tdate_ttodayRt datetime_RR%Rtappend(t territoryR4R3R8t non_tendertinclude_detailsRtcursR5tresultt currency_codeR1R2t is_tender((R3R4s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_territory_currenciess64      cCstj|jjddS(sReturn the symbol used by the locale to separate decimal fractions. >>> get_decimal_symbol('en_US') u'.' :param locale: the `Locale` object or locale identifier Ru.(RRtnumber_symbolsR%(R((s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_decimal_symbolscCstj|jjddS(sReturn 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+(RRRER%(R((s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_plus_sign_symbolscCstj|jjddS(sReturn 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-(RRRER%(R((s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_minus_sign_symbol scCstj|jjddS(sReturn 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(RRRER%(R((s1/usr/lib/python2.7/site-packages/babel/numbers.pytget_exponential_symbolscCstj|jjddS(sReturn 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,(RRRER%(R((s1/usr/lib/python2.7/site-packages/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((s1/usr/lib/python2.7/site-packages/babel/numbers.pyt format_number+s cCsFtj|}|s*|jj|}nt|}|j||S(uReturn 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(RPtformatRtpattern((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRO;s  tUnknownCurrencyFormatErrorcBseZdZRS(s>Exception raised when an unknown currency format is requested.(RRR(((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRWZststandardc Cstj|}|r$t|}n5y|j|}Wn!tk rXtd|nX|rzt|}||f}nd}|j||d|d|S(uReturn formatted currency value. >>> format_currency(1099.98, 'USD', locale='en_US') u'$1,099.98' >>> format_currency(1099.98, 'USD', locale='es_CO') u'US$\xa01.099,98' >>> format_currency(1099.98, 'EUR', locale='de_DE') u'1.099,98\xa0\u20ac' The format 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' Currencies usually have a specific number of decimal digits. This function favours that information over the given format: >>> format_currency(1099.98, 'JPY', locale='en_US') u'\xa51,100' >>> format_currency(1099.98, 'COP', u'#,##0.00', locale='es_ES') u'1.100' However, the number of decimal digits can be overriden from the currency information, by setting the last parameter to ``False``: >>> format_currency(1099.98, 'JPY', locale='en_US', currency_digits=False) u'\xa51,099.98' >>> format_currency(1099.98, 'COP', u'#,##0.00', locale='es_ES', currency_digits=False) u'1.099,98' If a format is not specified the type of currency format to use from the locale can be specified: >>> format_currency(1099.98, 'EUR', locale='en_US', format_type='standard') u'\u20ac1,099.98' When the given currency format type is not available, an exception is raised: >>> format_currency('1099.98', 'EUR', locale='root', format_type='unknown') Traceback (most recent call last): ... UnknownCurrencyFormatError: "'unknown' is not a known currency format type" :param number: the number to format :param currency: the currency code :param format: the format string to use :param locale: the `Locale` object or locale identifier :param currency_digits: use the currency's number of decimal digits :param format_type: the currency format type to use s&%r is not a known currency format typeRt force_fracN( RRRStcurrency_formatstKeyErrorRWR/R"RT( RPRRURtcurrency_digitst format_typeRVt precisiontfrac((s1/usr/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%RSRT(RPRURRV((s1/usr/lib/python2.7/site-packages/babel/numbers.pytformat_percents  cCsFtj|}|s*|jj|}nt|}|j||S(sReturn 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%RSRT(RPRURRV((s1/usr/lib/python2.7/site-packages/babel/numbers.pytformat_scientifics  tNumberFormatErrorcBseZdZRS(s>Exception raised when a string cannot be parsed into a number.(RRR(((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRescCsHy t|jt|dSWn!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(tinttreplaceRNt ValueErrorRe(tstringR((s1/usr/lib/python2.7/site-packages/babel/numbers.pyt parse_numbers  cCsotj|}y5tj|jt|djt|dSWn$tjk rjtd|nXdS(sParse 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 Rft.s %r is not a valid decimal numberN( RRRtDecimalRhRNRFtInvalidOperationRe(RjR((s1/usr/lib/python2.7/site-packages/babel/numbers.pyt parse_decimals s [^0-9@#.,]s [0-9@#.,E+]s(?P(?:'[^']*'|%s)*)s(?P%s+)s(?P.*)s%s%s%scCst|}|jd}|dkr+dS||d}|| d jd}|dkrg||fS|||d}||fS(sParse primary and secondary digit grouping >>> parse_grouping('##') (1000, 1000) >>> parse_grouping('#,###') (3, 3) >>> parse_grouping('#,####,###') (3, 4) t,iiii(ii(tlentrfind(tptwidthtg1tg2((s1/usr/lib/python2.7/site-packages/babel/numbers.pytparse_groupings    c Cst|tr|Sd}|}d|krs|jdd\}}||\}}}||\}}} n%||\}}}d|}|} d|kr|jdd\}} nd } d|krd|krd|krtd qnd|kr"|jdd\} } n |} d } d } | | }| | }| r| | | }| jd }| jd } | | }n d }d }t| }t|||f|| f|||||S(sParse number format patternscSs8tj|}|dkr.td|n|jS(NsInvalid number pattern %r(t number_retsearchR"Ritgroups(RVtrv((s1/usr/lib/python2.7/site-packages/babel/numbers.pyt _match_number9s t;it-tEt@Rlt0s5Significant digit patterns can not contain "@" or "0"RfcSstd}}x]|D]U}|dkr:|d7}|d7}q|dkrS|d7}q|dkreqqPqW||fS(s(Calculate the min and max allowed digitsis@0it#Rp((Rstmintmaxtc((s1/usr/lib/python2.7/site-packages/babel/numbers.pytparse_precisionXs        t+N( Rt NumberPatterntsplitR"Ritrsplitt startswithtlstripRw(RVR|t pos_patternt neg_patternt pos_prefixRPt pos_suffixt neg_prefixt_t neg_suffixtexptintegertfractionRtint_prect frac_prectexp_plustexp_prectgrouping((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRS4sH           RcBsGeZdZdZdddZdZdZddZRS(c Cs||_||_||_||_||_||_||_||_ddj|j|jkrsd|_ n4ddj|j|jkrd|_ n d|_ dS(Nt%Rfiu‰ii( RVtprefixtsuffixRRRRRtjointscale( RRVRRRRRRR((s1/usr/lib/python2.7/site-packages/babel/numbers.pyR zs          cCsdt|j|jfS(Ns<%s %r>(ttypeRRV(R((s1/usr/lib/python2.7/site-packages/babel/numbers.pyt__repr__sc CsI|p |j}t|tjs9tjt|}n|j|j}t|j}|j r|j }t |}|j d|j dkr||j dd8}n2|j drt||j d|j d}n|dkr|d| }n|d|}d}|dkr/t |}n|jrGt|}nt |}d|j||d|dt|||jt||j d|j d|f} nd|jkr7|jt ||j d|j d} | jd\} } } |j| dd|} | r| t|| 7} qntjd d |d}|j|}tt |jd\} } } |j| |j d|j d||j| pd ||} d |j|| |j|f}d |krE|jdt|||}|jd|j}|jd t||}n|S(Niii Rfu%s%s%s%sRRlis1.t1Ru%s%s%su¤u¤¤¤u¤¤(RRRRmtstrtscalebRRgt is_signedRtadjustedtabsRRJRRHt_format_significantRLt _format_intRVt partitionRFtquantizet _format_fracRRRhR)RR+(RtvalueRRRYRt is_negativeRtexp_signRPttexttatseptbR^troundedtretval((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRTs`    %      $  c Cs|j}|d|}t|j|jtjd}|dkr_|d| }n|| }t|} | t|| d} djd|pddddt |dd d || | !d || j dj d }|S( NiiRs-{intpart}.{pad:0<{fill}}{fracpart}{fracextra}tintparttpadRftfilltfracpartt fracextraRl( RRRRRRmRqRRURtrstrip( RRtminimumtmaximumRRtdigitsRARtitj((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRs  '       c Cst|}||kr-d|||}n|jd}d}t|}xAt||kr||| |}|| }|jd}qOW||S(NRiRfi(RqRRN( RRRRRRttgsizetrettsymbol((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRs     cCs|p |j\}}t||krB|d|t|7}n|dksl|dkrpt|dkrpdSx0t||kr|ddkr|d }qsWt||S(NRiRfi(RRqRgRF(RRRRYRR((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRs*%N( RRR RR"RTRRR(((s1/usr/lib/python2.7/site-packages/babel/numbers.pyRxs   J  (:RtreRRR9R;t itertoolsRt babel.coreRRRt babel._compatRRtbabel.localedataRR R R R"RRRR R)R+R/RRRDRFRHRJRLRNRQROR[RWR`RbRdRiReRkRot PREFIX_ENDt NUMBER_TOKENtPREFIX_PATTERNtNUMBER_PATTERNtSUFFIX_PATTERNtcompileRxRwRStobjectR(((s1/usr/lib/python2.7/site-packages/babel/numbers.pytsV       X J       D