changeset 182:2f30ce3fb85e trunk

Renamed `Attributes` to `Attrs` to reduce the verbosity.
author cmlenz
date Mon, 21 Aug 2006 20:03:13 +0000
parents e103b75a96ce
children 1f6ca5028770
files markup/builder.py markup/core.py markup/filters.py markup/input.py markup/plugin.py markup/template.py
diffstat 6 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/markup/builder.py
+++ b/markup/builder.py
@@ -11,7 +11,7 @@
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://markup.edgewall.org/log/.
 
-from markup.core import Attributes, Namespace, QName, Stream, START, END, TEXT
+from markup.core import Attrs, Namespace, QName, Stream, START, END, TEXT
 
 __all__ = ['Fragment', 'Element', 'tag']
 
@@ -157,7 +157,7 @@
     def __init__(self, tag_, **attrib):
         Fragment.__init__(self)
         self.tag = QName(tag_)
-        self.attrib = Attributes()
+        self.attrib = Attrs()
         for attr, value in attrib.items():
             if value is not None:
                 if not isinstance(value, basestring):
--- a/markup/core.py
+++ b/markup/core.py
@@ -156,13 +156,13 @@
         yield event
 
 
-class Attributes(list):
+class Attrs(list):
     """Sequence type that stores the attributes of an element.
     
     The order of the attributes is preserved, while accessing and manipulating
     attributes by name is also supported.
     
-    >>> attrs = Attributes([('href', '#'), ('title', 'Foo')])
+    >>> attrs = Attrs([('href', '#'), ('title', 'Foo')])
     >>> attrs
     [(u'href', '#'), (u'title', 'Foo')]
     
@@ -187,9 +187,9 @@
     >>> attrs
     [(u'href', '#'), (u'accesskey', 'k')]
     
-    An `Attributes` instance can also be initialized with keyword arguments.
+    An `Attrs` instance can also be initialized with keyword arguments.
     
-    >>> attrs = Attributes(class_='bar', href='#', title='Foo')
+    >>> attrs = Attrs(class_='bar', href='#', title='Foo')
     >>> attrs.get('class')
     'bar'
     >>> attrs.get('href')
@@ -200,7 +200,7 @@
     Reserved words can be used by appending a trailing underscore to the name,
     and any other underscore is replaced by a dash:
     
-    >>> attrs = Attributes(class_='bar', accept_charset='utf-8')
+    >>> attrs = Attrs(class_='bar', accept_charset='utf-8')
     >>> attrs.get('class')
     'bar'
     >>> attrs.get('accept-charset')
@@ -212,7 +212,7 @@
     __slots__ = []
 
     def __init__(self, attrib=None, **kwargs):
-        """Create the `Attributes` instance.
+        """Create the `Attrs` instance.
         
         If the `attrib` parameter is provided, it is expected to be a sequence
         of `(name, value)` tuples.
--- a/markup/filters.py
+++ b/markup/filters.py
@@ -19,7 +19,7 @@
     from sets import ImmutableSet as frozenset
 import re
 
-from markup.core import Attributes, Namespace, stripentities
+from markup.core import Attrs, Namespace, stripentities
 from markup.core import END, END_NS, START, START_NS
 
 __all__ = ['HTMLSanitizer', 'IncludeFilter']
@@ -67,7 +67,7 @@
                     waiting_for = tag
                     continue
 
-                new_attrib = Attributes()
+                new_attrib = Attrs()
                 for attr, value in attrib:
                     value = stripentities(value)
                     if attr not in self._SAFE_ATTRS:
--- a/markup/input.py
+++ b/markup/input.py
@@ -21,7 +21,7 @@
 import htmlentitydefs
 from StringIO import StringIO
 
-from markup.core import Attributes, QName, Stream
+from markup.core import Attrs, QName, Stream
 from markup.core import DOCTYPE, START, END, START_NS, END_NS, TEXT, \
                         START_CDATA, END_CDATA, PI, COMMENT
 
@@ -146,7 +146,7 @@
                 self.expat.CurrentColumnNumber)
 
     def _handle_start(self, tag, attrib):
-        self._enqueue(START, (QName(tag), Attributes(zip(*[iter(attrib)] * 2))))
+        self._enqueue(START, (QName(tag), Attrs(zip(*[iter(attrib)] * 2))))
 
     def _handle_end(self, tag):
         self._enqueue(END, QName(tag))
@@ -268,7 +268,7 @@
                 value = name
             fixed_attrib.append((name, unicode(value)))
 
-        self._enqueue(START, (QName(tag), Attributes(fixed_attrib)))
+        self._enqueue(START, (QName(tag), Attrs(fixed_attrib)))
         if tag in self._EMPTY_ELEMS:
             self._enqueue(END, QName(tag))
         else:
--- a/markup/plugin.py
+++ b/markup/plugin.py
@@ -18,7 +18,7 @@
 
 from pkg_resources import resource_filename
 
-from markup.core import Attributes, Stream, QName
+from markup.core import Attrs, Stream, QName
 from markup.template import Context, Template, TemplateLoader
 
 def et_to_stream(element):
--- a/markup/template.py
+++ b/markup/template.py
@@ -24,7 +24,7 @@
 import re
 from StringIO import StringIO
 
-from markup.core import Attributes, Namespace, Stream, StreamEventKind, _ensure
+from markup.core import Attrs, Namespace, Stream, StreamEventKind, _ensure
 from markup.core import START, END, START_NS, END_NS, TEXT, COMMENT
 from markup.eval import Expression
 from markup.input import XMLParser
@@ -209,7 +209,7 @@
             kind, (tag, attrib), pos  = stream.next()
             attrs = self.expr.evaluate(ctxt)
             if attrs:
-                attrib = Attributes(attrib[:])
+                attrib = Attrs(attrib[:])
                 if isinstance(attrs, Stream):
                     try:
                         attrs = iter(attrs).next()
@@ -795,7 +795,7 @@
                                                      self._dir_order.index(b.__class__)))
                     dirmap[(depth, tag)] = (directives, len(stream), strip)
 
-                stream.append((kind, (tag, Attributes(new_attrib)), pos))
+                stream.append((kind, (tag, Attrs(new_attrib)), pos))
                 depth += 1
 
             elif kind is END:
@@ -919,7 +919,7 @@
                         if not value:
                             continue
                     new_attrib.append((name, u''.join(value)))
-                yield kind, (tag, Attributes(new_attrib)), pos
+                yield kind, (tag, Attrs(new_attrib)), pos
 
             elif kind is EXPR:
                 result = data.evaluate(ctxt)
Copyright (C) 2012-2017 Edgewall Software