Package pytils :: Module numeral
[show private | hide private]
[frames | no frames]

Module pytils.numeral

Plural forms and in-word representation for numerals.
Function Summary
unicode choose_plural(amount, variants)
Choose proper case depending on amount

unicode

raise TypeError: when amount not int or float
in_words(amount, gender)
Numeral in words
unicode in_words_float(amount, gender)
Float in words
unicode in_words_int(amount, gender)
Integer in words
unicode rubles(amount, zero_for_kopeck)
Get string for money
unicode sum_string(amount, gender, items)
Get sum in words
tuple __sum_string_fn(into, tmp_val, gender, items)
Make in-words representation of single order
str _get_float_remainder(fvalue, signs)
Get remainder of float, i.e.

Function Details

choose_plural(amount, variants)

Choose proper case depending on amount
Parameters:
amount - amount of objects
           (type=int)
variants - variants (forms) of object in such form: (1 object, 2 objects, 5 objects).
           (type=3-element sequence of unicode)
Returns:
proper variant
           (type=unicode)

in_words(amount, gender=None)

Numeral in words
Parameters:
amount - numeral
           (type=int or float)
gender - gender (male=1, female=2, neuter=3)
           (type=int)
Returns:
in-words reprsentation of numeral
           (type=

unicode

raise TypeError: when amount not int or float)

in_words_float(amount, gender=2)

Float in words
Parameters:
amount - float numeral
           (type=float)
gender - gender (male=1, female=2, neuter=3)
           (type=int)
Returns:
in-words reprsentation of float numeral
           (type=unicode)
Raises:
AssertionError - when amount is not float

in_words_int(amount, gender=1)

Integer in words
Parameters:
amount - numeral
           (type=int)
gender - gender (male=1, female=2, neuter=3)
           (type=int)
Returns:
in-words reprsentation of numeral
           (type=unicode)
Raises:
AssertionError - when amount is not int

rubles(amount, zero_for_kopeck=False)

Get string for money
Parameters:
amount - amount of money
           (type=int or float)
zero_for_kopeck - If false, then zero kopecks ignored
           (type=bool)
Returns:
in-words representation of money's amount
           (type=unicode)
Raises:
AssertionError - input parameters' check failed

sum_string(amount, gender, items=None)

Get sum in words
Parameters:
amount - amount of objects
           (type=int)
gender - gender of object (male=1, female=2, neuter=3)
           (type=int)
items - variants of object in three forms: for one object, for two objects and for five objects
           (type=3-element sequence of unicode)
Returns:
in-words representation objects' amount
           (type=unicode)
Raises:
AssertionError - input parameters' check failed

__sum_string_fn(into, tmp_val, gender, items=None)

Make in-words representation of single order
Parameters:
into - in-words representation of lower orders
           (type=unicode)
tmp_val - temporary value without lower orders
           (type=int)
gender - gender (male=1, female=2, neuter=3)
           (type=int)
items - variants of objects
           (type=3-element sequence of unicode)
Returns:
new into and tmp_val
           (type=tuple)
Raises:
AssertionError - input parameters' check failed

_get_float_remainder(fvalue, signs=9)

Get remainder of float, i.e. 2.05 -> '05'
Parameters:
fvalue - input value
           (type=int or float)
signs - maximum number of signs
           (type=int)
Returns:
remainder
           (type=str)

Generated by Epydoc 2.1 on Sat Sep 2 23:16:44 2006 http://epydoc.sf.net