Code

Ticket #11636: humanize.patch

File humanize.patch, 690 bytes (added by bymenda, 5 years ago)
  • .py

    old new  
    3737intcomma.is_safe = True 
    3838register.filter(intcomma) 
    3939 
     40def intdot(value): 
     41    """ 
     42    Converts an integer to a string containing dots every three digits. 
     43    For example, 3000 becomes '3.000' and 45000 becomes '45.000'. 
     44    """ 
     45    orig = force_unicode(value) 
     46    new = re.sub("^(-?\d+)(\d{3})", '\g<1>.\g<2>', orig) 
     47    if orig == new: 
     48        return new 
     49    else: 
     50        return intdot(new) 
     51intdot.is_safe = True 
     52register.filter(intdot) 
     53 
    4054def intword(value): 
    4155    """ 
    4256    Converts a large integer to a friendly text representation. Works best for