Changeset 2508:180fc9002394 in livinglogic.python.xist

Show
Ignore:
Timestamp:
04/26/06 15:53:56 (14 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Drop PlainPresenter?, as now we have simple repr methods for all
classes, and that was the only use of the PlainPresenter?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • _xist/presenters.py

    r2506 r2508  
    313313        <par>present an <pyref module="ll.xist.xsc" class="Attr"><class>Attr</class></pyref> node.</par> 
    314314        """ 
    315  
    316  
    317 class PlainPresenter(Presenter): 
    318     """ 
    319     <par>This presenter shows only the root node of the tree (with a little additional 
    320     information about the number of nested nodes).</par> 
    321     """ 
    322     def __init__(self, node, maxlen=60): 
    323         Presenter.__init__(self, node) 
    324         self.maxlen = maxlen 
    325  
    326     def presentCharacterData(self, node): 
    327         content = node.content 
    328         if len(content)>self.maxlen: 
    329             content = u"%s...%s" % (content[:self.maxlen/2], content[-self.maxlen/2:]) 
    330         yield astyle.default(u"<", s4ns(unicode(node.__class__.__module__)), u":", unicode(node.__class__.__fullname__()), u" object content=", unicode(repr(content)), u" at ", s4id(u"0x%x" % id(node)), u">") 
    331  
    332     presentText = presentCharacterData 
    333  
    334     def presentFrag(self, node): 
    335         l = len(node) 
    336         if l==0: 
    337             info = u"no children" 
    338         elif l==1: 
    339             info = u"1 child" 
    340         else: 
    341             info = u"%d children" % l 
    342         yield astyle.default(u"<", node._str(fullname=True, xml=False, decorate=False), u" object (", info, u") at ", s4id(u"0x%x" % id(node)), u">") 
    343  
    344     def presentAttr(self, node): 
    345         l = len(node) 
    346         if l==0: 
    347             info = u"no children" 
    348         elif l==1: 
    349             info = u"1 child" 
    350         else: 
    351             info = u"%d children" % l 
    352         yield astyle.default(u"<", node._str(fullname=True, xml=False, decorate=False), u" attr object (", info, u") at ", s4id(u"0x%x" % id(node)), u">") 
    353  
    354     presentComment = presentCharacterData 
    355     presentDocType = presentCharacterData 
    356     def presentProcInst(self, node): 
    357         content = node.content 
    358         if len(content)>self.maxlen: 
    359             content = content[:self.maxlen/2] + u"..." + content[-self.maxlen/2:] 
    360         yield astyle.default(u"<", node._str(fullname=True, xml=False, decorate=False), u" procinst object content=", repr(content), u") at ", s4id(u"0x%x" % id(node)), u">") 
    361  
    362     def presentAttrs(self, node): 
    363         l = len(node) 
    364         if l==0: 
    365             info = u"(no attrs)" 
    366         elif l==1: 
    367             info = u"(1 attr)" 
    368         else: 
    369             info = u"(%d attrs)" % l 
    370         yield astyle.default(u"<", node._str(fullname=True, xml=False, decorate=False), u" attrs object ", info, u" at ", s4id(u"0x%x" % id(node)), u">") 
    371  
    372     def presentElement(self, node): 
    373         lc = len(node.content) 
    374         if lc==0: 
    375             infoc = u"no children" 
    376         elif lc==1: 
    377             infoc = u"1 child" 
    378         else: 
    379             infoc = u"%d children" % lc 
    380         la = len(node.attrs) 
    381         if la==0: 
    382             infoa = u"no attrs" 
    383         elif la==1: 
    384             infoa = u"1 attr" 
    385         else: 
    386             infoa = u"%d attrs" % la 
    387         yield astyle.default(u"<", node._str(fullname=True, xml=False, decorate=False), u" element object (", infoc, u"/", infoa, u") at ", s4id(u"0x%x" % id(node)), u">") 
    388  
    389     def presentEntity(self, node): 
    390         yield astyle.default(u"<", node._str(fullname=True, xml=False, decorate=False), u" entity object at ", s4id(u"0x%x" % id(node)), u">") 
    391  
    392     def presentNull(self, node): 
    393         yield astyle.default(u"<", node._str(fullname=True, xml=False, decorate=False), u" object at ", s4id(u"0x%x" % id(node)), u">") 
    394315 
    395316