Changeset 3440:e9732c5765c6 in livinglogic.python.xist

Show
Ignore:
Timestamp:
07/03/08 18:28:32 (11 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Implement format for the rest of the types by reusing a module from the Python SVN repo.

Location:
src/ll
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/ul4c.py

    r3439 r3440  
    2424 
    2525 
    26 import re, datetime, marshal, StringIO 
     26import re, datetime, marshal, StringIO, locale 
    2727 
    2828from ll import spark 
     
    19401940 
    19411941 
     1942### 
     1943### Helper functions use at template runtime 
     1944### 
     1945 
    19421946def _oct(value): 
    19431947    """ 
     
    19701974 
    19711975 
     1976_format_int = re.compile("(.??)([<=>^]?)([-+ ])?(0?)(\\d+)([bcdoxXn]?)") 
     1977 
    19721978def _format(obj, format): 
    19731979    """ 
     
    19781984            format = format.replace("%f", "%06d" % obj.microsecond) # FIXME: This would replace "%%f", which is wrong (wait for Python 2.6?) 
    19791985        return obj.strftime(format.encode("utf-8")) 
     1986    elif obj is None or isinstance(obj, (int, long, float, str, unicode)): 
     1987        from ll import stringformat 
     1988        return stringformat.format_builtin_type(obj, format) 
    19801989    else: 
    1981         return obj.format(format) # This will raise a ``AttributeError`` 
     1990        return obj.format(format) # This will raise an ``AttributeError`` 
    19821991 
    19831992