[Docstring-checkins] CVS: dps/dps nodes.py,1.37,1.38
Status: Pre-Alpha
Brought to you by:
goodger
From: David G. <go...@us...> - 2002-03-28 04:46:27
|
Update of /cvsroot/docstring/dps/dps In directory usw-pr-cvs1:/tmp/cvs-serv20484/dps/dps Modified Files: nodes.py Log Message: - Added support for list-value attributes (including "Element.setdefault()"). - Added "BackLinkable" mixin. Index: nodes.py =================================================================== RCS file: /cvsroot/docstring/dps/dps/nodes.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** nodes.py 16 Mar 2002 06:07:41 -0000 1.37 --- nodes.py 28 Mar 2002 04:46:24 -0000 1.38 *************** *** 8,11 **** --- 8,13 ---- :Copyright: This module has been placed in the public domain. + Docutils document tree element class library. + Classes in CamelCase are abstract base classes or auxiliary classes. The one exception is `Text`, for a text node; uppercase is used to differentiate from *************** *** 20,24 **** import sys, os import xml.dom.minidom ! from types import IntType, SliceType, StringType, TupleType from UserString import MutableString from dps import utils --- 22,26 ---- import sys, os import xml.dom.minidom ! from types import IntType, SliceType, StringType, TupleType, ListType from UserString import MutableString from dps import utils *************** *** 241,247 **** def starttag(self): ! return '<%s>' % ' '.join([self.tagname] + ! ['%s="%s"' % (n, v) ! for n, v in self.attlist()]) def endtag(self): --- 243,256 ---- def starttag(self): ! parts = [self.tagname] ! for name, value in self.attlist: ! if value is None: # boolean attribute ! parts.append(name) ! elif isinstance(value, ListType): ! values = [str(v) for v in value] ! parts.append('%s="%s"' % (name, ' '.join(values))) ! else: ! parts.append('%s="%s"' % (name, str(value))) ! return '<%s>' % ' '.join(parts) def endtag(self): *************** *** 327,330 **** --- 336,342 ---- return self.attributes.has_key(attr) + def setdefault(self, key, failobj=None): + return self.attributes.setdefault(key, failobj) + has_key = hasattr *************** *** 440,443 **** --- 452,461 ---- + class BackLinkable: + + def add_refid(self, refid): + self.setdefault('refid', []).append(refid) + + # ==================== # Element Categories *************** *** 580,584 **** id = node['id'] if self.ids.has_key(id) and self.ids[id] is not node: ! msg = self.reporter.error('Duplicate ID: "%s"' % id) msgnode += msg else: --- 598,602 ---- id = node['id'] if self.ids.has_key(id) and self.ids[id] is not node: ! msg = self.reporter.error('Duplicate ID: "%s".' % id) msgnode += msg else: *************** *** 594,603 **** if node.has_key('name'): name = node['name'] - #if self.nameids.has_key(name) \ - # and self.ids[self.nameids[name]].has_key('name'): - # msg = self.reporter.info( - # 'Multiple IDs for name "%s": "%s", "%s"' - # % (name, self.nameids[name], id)) - # msgnode += msg self.nameids[name] = id return id --- 612,615 ---- *************** *** 611,615 **** or self.implicit_targets.has_key(name): msg = self.reporter.info( ! 'Duplicate implicit target name: "%s"' % name, refid=id) msgnode += msg self.clear_target_names(name, self.implicit_targets) --- 623,627 ---- or self.implicit_targets.has_key(name): msg = self.reporter.info( ! 'Duplicate implicit target name: "%s".' % name, refid=id) msgnode += msg self.clear_target_names(name, self.implicit_targets) *************** *** 632,636 **** level = 1 # just inform if refuri's identical msg = self.reporter.system_message( ! level, 'Duplicate explicit target name: "%s"' % name, refid=id) msgnode += msg --- 644,648 ---- level = 1 # just inform if refuri's identical msg = self.reporter.system_message( ! level, 'Duplicate explicit target name: "%s".' % name, refid=id) msgnode += msg *************** *** 642,646 **** elif self.implicit_targets.has_key(name): msg = self.reporter.info( ! 'Duplicate implicit target name: "%s"' % name, refid=id) msgnode += msg self.clear_target_names(name, self.implicit_targets) --- 654,658 ---- elif self.implicit_targets.has_key(name): msg = self.reporter.info( ! 'Duplicate implicit target name: "%s".' % name, refid=id) msgnode += msg self.clear_target_names(name, self.implicit_targets) *************** *** 696,700 **** if self.substitution_defs.has_key(name): msg = self.reporter.error( ! 'Duplicate substitution definition name: "%s"' % name) if msgnode == None: msgnode = self.messages --- 708,712 ---- if self.substitution_defs.has_key(name): msg = self.reporter.error( ! 'Duplicate substitution definition name: "%s".' % name) if msgnode == None: msgnode = self.messages *************** *** 824,829 **** class substitution_definition(Special, TextElement): pass class target(Special, Inline, TextElement, ToBeResolved): pass ! class footnote(General, Element): pass ! class citation(General, Element): pass class label(Component, TextElement): pass class figure(General, Element): pass --- 836,841 ---- class substitution_definition(Special, TextElement): pass class target(Special, Inline, TextElement, ToBeResolved): pass ! class footnote(General, Element, BackLinkable): pass ! class citation(General, Element, BackLinkable): pass class label(Component, TextElement): pass class figure(General, Element): pass *************** *** 839,843 **** ! class system_message(Special, PreBibliographic, Element): def __init__(self, comment=None, *children, **attributes): --- 851,855 ---- ! class system_message(Special, PreBibliographic, Element, BackLinkable): def __init__(self, comment=None, *children, **attributes): *************** *** 855,859 **** """ - The "pending" element is used to encapsulate a pending operation: the operation, the point at which to apply it, and any data it requires. Only --- 867,870 ---- *************** *** 891,895 **** self.details = details ! """Detail data required by the pending operation.""" def pformat(self, indent=' ', level=0): --- 902,906 ---- self.details = details ! """Detail data (dictionary) required by the pending operation.""" def pformat(self, indent=' ', level=0): |