uilib.py
changeset 10612 84468b90e9c1
parent 10332 da1cb2b12fe1
child 10613 8d9fe02387e3
equal deleted inserted replaced
10611:f4dec0cca9a1 10612:84468b90e9c1
    25 __docformat__ = "restructuredtext en"
    25 __docformat__ = "restructuredtext en"
    26 
    26 
    27 import csv
    27 import csv
    28 import re
    28 import re
    29 from StringIO import StringIO
    29 from StringIO import StringIO
       
    30 
       
    31 from six import string_types
    30 
    32 
    31 from logilab.mtconverter import xml_escape, html_unescape
    33 from logilab.mtconverter import xml_escape, html_unescape
    32 from logilab.common.date import ustrftime
    34 from logilab.common.date import ustrftime
    33 from logilab.common.deprecation import deprecated
    35 from logilab.common.deprecation import deprecated
    34 
    36 
   557         self.maxsize = maxsize
   559         self.maxsize = maxsize
   558 
   560 
   559     def __call__(self, function):
   561     def __call__(self, function):
   560         def newfunc(*args, **kwargs):
   562         def newfunc(*args, **kwargs):
   561             ret = function(*args, **kwargs)
   563             ret = function(*args, **kwargs)
   562             if isinstance(ret, basestring):
   564             if isinstance(ret, string_types):
   563                 return ret[:self.maxsize]
   565                 return ret[:self.maxsize]
   564             return ret
   566             return ret
   565         return newfunc
   567         return newfunc
   566 
   568 
   567 
   569 
   568 def htmlescape(function):
   570 def htmlescape(function):
   569     def newfunc(*args, **kwargs):
   571     def newfunc(*args, **kwargs):
   570         ret = function(*args, **kwargs)
   572         ret = function(*args, **kwargs)
   571         assert isinstance(ret, basestring)
   573         assert isinstance(ret, string_types)
   572         return xml_escape(ret)
   574         return xml_escape(ret)
   573     return newfunc
   575     return newfunc