Ñò e>õGc @s¦dZddkZddkZedddd„Zdddd d „Zd dd „Zd d„Zd„Zd dd„Z d d„Z dddddddgZ dS(sÆ Number Helpers Provides methods for converting numbers into formatted strings. Functions are provided for phone numbers, currencies, percentages, precision, positional notation, and file size. iÿÿÿÿNt-tcCs£t|ƒiƒ}|otidd||ƒ}n tidd||f|ƒ}|o%t|ƒiƒo|d|7}n|od|||f}n|S(sE Format a ``number`` into a US phone number string. ``area_code`` When enabled, adds parentheses around the area code. Defaults to False. ``delimiter`` The delimiter to use, defaults to "-". ``extension`` Specifies an extension to add to the end of the generated number. ``country_code`` Sets the country code for the phone number. Examples:: >>> number_to_phone(1235551234) '123-555-1234' >>> number_to_phone(1235551234, area_code=True) '(123) 555-1234' >>> number_to_phone(1235551234, delimiter=" ") '123 555 1234' >>> number_to_phone(1235551234, area_code=True, extension=555) '(123) 555-1234 x 555' >>> number_to_phone(1235551234, country_code=1) '1-123-555-1234' s ([0-9]{1,3})([0-9]{3})([0-9]{4})s (\1) \2%s\3s \1%s\2%s\3s x %ss%s%s%s(tstrtstriptretsub(tnumbert area_codet delimitert extensiont country_code((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pytnumber_to_phone s  t$it.t,cCss|djo d}nt||ƒidƒ}|t|d|ƒ}t|ƒdjo|||d7}n|S(s› Format a ``number`` into a currency string. ``precision`` Indicates the level of precision. Defaults to 2. ``unit`` Sets the currency type. Defaults to "$". ``separator`` Used to set what the unit separation should be. Defaults to ".". ``delimiter`` The delimiter character to use. Defaults to ",". Examples:: >>> number_to_currency(1234567890.50) '$1,234,567,890.50' >>> number_to_currency(1234567890.506) '$1,234,567,890.51' >>> number_to_currency(1234567890.50, unit="£", separator=",", delimiter="") '£1234567890,50' iRR i(tnumber_with_precisiontsplittnumber_with_delimitertlen(Rtunitt precisiont separatorRtpartstnum((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pytnumber_to_currency6s  icCsZt||ƒ}|idƒ}t|ƒdjo |ddS|d||ddSdS(s° Format a ``number`` as into a percentage string. ``precision`` The level of precision, defaults to 3 ``separator`` The unit separator to be used. Defaults to "." Examples:: >>> number_to_percentage(100) '100.000%' >>> number_to_percentage(100, precision=0) '100%' >>> number_to_percentage(302.0574, precision=2) '302.06%' R iit%iN(RRR(RRRR((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pytnumber_to_percentageUs  icCs¨|djodS|djo d|S|djod||dS|djod ||dS|djod ||dS|djod ||dSdSdS(s: Return a formatted-for-humans file size. ``precision`` The level of precision, defaults to 1 Examples:: >>> number_to_human_size(123) '123 Bytes' >>> number_to_human_size(1234) '1.2 KB' >>> number_to_human_size(12345) '12.1 KB' >>> number_to_human_size(1234567) '1.2 MB' >>> number_to_human_size(1234567890) '1.1 GB' >>> number_to_human_size(1234567890123) '1.1 TB' >>> number_to_human_size(1234567, 2) '1.18 MB' is1 Byteis%d Bytesis %%.%if KBg@is %%.%if MBis %%.%if GBis %%.%if TBRNii@g0AlgÐAl gpB((tsizeR((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pytnumber_to_human_sizeos       cOs tidtdƒt||ŽS(s-Deprecated: Use number_to_human_size instead.sUThe human_size function has been deprecated, please use number_to_human_size instead.i(twarningstwarntDeprecationWarningR(targstkwargs((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pyt human_size—s  cCsIt|ƒidƒ}tidd|t|dƒƒ|d<|i|ƒS(sç Format a ``number`` with grouped thousands using ``delimiter``. ``delimiter`` The delimiter character to use, defaults to "," ``separator`` Used to set what the unit separation should be. Defaults to "." Example:: >>> number_with_delimiter(12345678) '12,345,678' >>> number_with_delimiter(12345678.05) '12,345,678.05' >>> number_with_delimiter(12345678, delimiter=".") '12.345.678' R s(\d)(?=(\d\d\d)+(?!\d))s\1%si(RRRRtjoin(RRRR((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pyRs'cCsdt|ƒd}||S(s Format a ``number`` with a level of ``precision``. ``precision`` The level of precision, defaults to 3 Example:: >>> number_with_precision(111.2346) '111.235' >>> number_with_precision(111.2346, 2) '111.23' s%01.tf(R(RRtformstr((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pyR´sR RRRRRR"( t__doc__RRtFalseR RRRR"RRt__all__(((s;/usr/lib/python2.6/site-packages/webhelpers/rails/number.pyts  ) (