summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-03-26 20:11:28 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-03-26 20:11:28 +0000
commit713cd407a320d79424a2e59d5dfc50ccb31de930 (patch)
treec2783a08f0c292d66f4f101f45cb48675d43f171
parent26d34fdcecffd31a4234e8ac4c190bde696dbb76 (diff)
downloaddocutils-713cd407a320d79424a2e59d5dfc50ccb31de930.tar.gz
simplified creation of attributes;
there is some redundancy now (the dictionary appears twice), and the backrefs attribute is set not only for BackLinkable nodes but for all Elements, but for simplicity that is OK, IMO; and after all, it provides quite a significant speedup git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3136 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--HISTORY.txt3
-rw-r--r--docutils/nodes.py13
2 files changed, 6 insertions, 10 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index a89dac67c..b7c447292 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -38,8 +38,7 @@ Changes Since 0.3.7
TextElement (it's an empty element, and cannot contain text).
- Added ``attr_defaults`` dictionary for default attribute values.
- Added empty list as default value for the following attributes:
- ``ids``, ``names``, ``dupnames``, ``classes`` for Element nodes,
- and additionally ``backrefs`` for BackLinkable nodes.
+ ``ids``, ``names``, ``dupnames``, ``classes``, and ``backrefs``.
* docutils/languages/nl.py: Added to project; Dutch mappings by
Martijn Pieters.
diff --git a/docutils/nodes.py b/docutils/nodes.py
index 021c2dbf0..b6c34e359 100644
--- a/docutils/nodes.py
+++ b/docutils/nodes.py
@@ -27,7 +27,6 @@ import sys
import os
import re
import xml.dom.minidom
-from copy import deepcopy
from types import IntType, SliceType, StringType, UnicodeType, \
TupleType, ListType
from UserString import UserString
@@ -327,9 +326,9 @@ class Element(Node):
This is equivalent to ``element.extend([node1, node2])``.
"""
- attr_defaults = {'ids': [], 'classes': [], 'names': [], 'dupnames': []}
- """Default attributes. ``attributes`` is initialized with a copy
- of ``attr_defaults``."""
+ attr_defaults = {'ids': [], 'classes': [], 'names': [],
+ 'dupnames': [], 'backrefs': []}
+ """Default attributes."""
tagname = None
"""The element generic identifier. If None, it is set as an instance
@@ -347,7 +346,8 @@ class Element(Node):
self.extend(children) # maintain parent info
- self.attributes = deepcopy(self.attr_defaults)
+ self.attributes = {'ids': [], 'classes': [], 'names': [],
+ 'dupnames': [], 'backrefs': []}
"""Dictionary of attribute {name: value}."""
for att, value in attributes.items():
@@ -664,9 +664,6 @@ class Resolvable:
class BackLinkable:
- attr_defaults = Element.attr_defaults.copy()
- attr_defaults['backrefs'] = []
-
def add_backref(self, refid):
self['backrefs'].append(refid)