Esempio n. 1
0
 def short_value(self):
     if self.is_scalar:
         if isinstance(self.value, basestring):
             value = self.value
             if not isinstance(self.value, unicode):
                 value = unicode(self.value, 'utf-8', 'replace')
             return tag.q(shorten_line(value, 60)).generate()
         else:
             return shorten_line(repr(self.value), 60)
     elif self.is_collection:
         if isinstance(self.value, (dict, DictMixin)):
             return u'{…}'
         elif isinstance(self.value, list):
             return u'[…]'
         elif isinstance(self.value, tuple):
             return u'(…)'
         elif isinstance(self.value, set):
             return u'set([…])'
         elif isinstance(self.value, frozenset):
             return u'frozenset([…])'
     else:
         try:
             return tag.code(shorten_line(str(self.value), 60))
         except:
             return '?'
Esempio n. 2
0
 def expand_macro(self, formatter, name, content, args=None):
     raise ProcessorError(
         tag_("The content: %(content)s", content=html.code(content)))