Thread: [Docstring-checkins] CVS: dps/dps nodes.py,1.7,1.8
Status: Pre-Alpha
Brought to you by:
goodger
From: David G. <go...@us...> - 2001-09-10 04:17:40
|
Update of /cvsroot/docstring/dps/dps In directory usw-pr-cvs1:/tmp/cvs-serv19823/dps/dps Modified Files: nodes.py Log Message: - Changed 'tagName' to 'tagname'. - Improved auto-tagname generation. - Added string-conversion to attribute values in DOM-conversion. - Changed footnote/footnote_reference 'auto' attribute to integer. - Moved 'abstract' into bibliographic elements section. - Changed 'graphic' to 'image'. Index: nodes.py =================================================================== RCS file: /cvsroot/docstring/dps/dps/nodes.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** nodes.py 2001/09/07 02:08:41 1.7 --- nodes.py 2001/09/10 04:17:38 1.8 *************** *** 39,43 **** class Text(_Node, MutableString): ! tagName = '#text' def __repr__(self): --- 39,43 ---- class Text(_Node, MutableString): ! tagname = '#text' def __repr__(self): *************** *** 45,49 **** if len(data) > 70: data = repr(self.data[:64] + ' ...') ! return '<%s: %s>' % (self.tagName, data) def _dom_node(self, dom): --- 45,49 ---- if len(data) > 70: data = repr(self.data[:64] + ' ...') ! return '<%s: %s>' % (self.tagname, data) def _dom_node(self, dom): *************** *** 90,94 **** element += [node1, node2] """ ! childtextsep = '\n\n' """Separator for child nodes, used by `astext()` method.""" --- 90,98 ---- element += [node1, node2] """ ! ! tagname = None ! """The element generic identifier. If None, it is set as an instance ! attribute to the name of the class.""" ! childtextsep = '\n\n' """Separator for child nodes, used by `astext()` method.""" *************** *** 104,114 **** """Dictionary of attribute {name: value}.""" ! self.tagName = self.__class__.__name__ ! """The element generic identifier, usually the class name.""" def _dom_node(self, dom): ! element = dom.Element(self.tagName) for attribute, value in self.attributes.items(): ! element.setAttribute(attribute, value) for child in self.children: element.appendChild(child._dom_node(dom)) --- 108,118 ---- """Dictionary of attribute {name: value}.""" ! if self.tagname is None: ! self.tagname = self.__class__.__name__ def _dom_node(self, dom): ! element = dom.Element(self.tagname) for attribute, value in self.attributes.items(): ! element.setAttribute(attribute, str(value)) for child in self.children: element.appendChild(child._dom_node(dom)) *************** *** 116,122 **** def _rooted_dom_node(self, domroot): ! element = domroot.createElement(self.tagName) for attribute, value in self.attributes.items(): ! element.setAttribute(attribute, value) for child in self.children: element.appendChild(child._rooted_dom_node(domroot)) --- 120,126 ---- def _rooted_dom_node(self, domroot): ! element = domroot.createElement(self.tagname) for attribute, value in self.attributes.items(): ! element.setAttribute(attribute, str(value)) for child in self.children: element.appendChild(child._rooted_dom_node(domroot)) *************** *** 126,130 **** data = '' for c in self.children: ! data += '<%s...>' % c.tagName if len(data) > 60: data = data[:56] + ' ...' --- 130,134 ---- data = '' for c in self.children: ! data += '<%s...>' % c.tagname if len(data) > 60: data = data[:56] + ' ...' *************** *** 141,153 **** def starttag(self): ! return '<%s>' % ' '.join([self.tagName] + ['%s="%s"' % (n, v) for n, v in self.attlist()]) def endtag(self): ! return '</%s>' % self.tagName def emptytag(self): ! return '<%s/>' % ' '.join([self.tagName] + ['%s="%s"' % (n, v) for n, v in self.attlist()]) --- 145,157 ---- def starttag(self): ! return '<%s>' % ' '.join([self.tagname] + ['%s="%s"' % (n, v) for n, v in self.attlist()]) def endtag(self): ! return '</%s>' % self.tagname def emptytag(self): ! return '<%s/>' % ' '.join([self.tagname] + ['%s="%s"' % (n, v) for n, v in self.attlist()]) *************** *** 394,402 **** def addautofootnote(self, name, footnotenode): ! footnotenode['auto'] = '1' self.autofootnotes.append((name, footnotenode)) def addautofootnoteref(self, refname, refnode): ! refnode['auto'] = '1' self.autofootnoterefs.append((refname, refnode)) --- 398,406 ---- def addautofootnote(self, name, footnotenode): ! footnotenode['auto'] = 1 self.autofootnotes.append((name, footnotenode)) def addautofootnoteref(self, refname, refnode): ! refnode['auto'] = 1 self.autofootnoterefs.append((refname, refnode)) *************** *** 417,420 **** --- 421,425 ---- class date(_TextElement): pass class copyright(_TextElement): pass + class abstract(_Element): pass *************** *** 423,427 **** # ===================== - class abstract(_Element): pass class section(_Element): pass --- 428,431 ---- *************** *** 525,529 **** class link(_TextElement): pass class footnote_reference(_TextElement): pass ! class graphic(_TextElement): pass class package(_TextElement): pass --- 529,533 ---- class link(_TextElement): pass class footnote_reference(_TextElement): pass ! class image(_TextElement): pass class package(_TextElement): pass *************** *** 533,539 **** class inline_class(_TextElement): ! def __init__(self, *args, **kwargs): ! _TextElement.__init__(self, *args, **kwargs) ! self.tagName = 'class' --- 537,541 ---- class inline_class(_TextElement): ! tagname = 'class' |