changeset 27:b4f78c05e5c9 trunk

* Fix the boilerplate in the Python source files. * Some more docstrings and cosmetic fixes.
author cmlenz
date Wed, 28 Jun 2006 09:28:09 +0000
parents 3c1a022be04c
children 35956040ba6e
files markup/__init__.py markup/builder.py markup/core.py markup/eval.py markup/filters.py markup/input.py markup/output.py markup/path.py markup/plugin.py markup/template.py markup/tests/__init__.py markup/tests/builder.py markup/tests/core.py markup/tests/eval.py markup/tests/input.py markup/tests/output.py markup/tests/path.py markup/tests/template.py setup.py
diffstat 19 files changed, 66 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/markup/__init__.py
+++ b/markup/__init__.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 """This package provides various means for generating and processing web markup
 (XML or HTML).
--- a/markup/builder.py
+++ b/markup/builder.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 from markup.core import Attributes, Namespace, QName, Stream
 
--- a/markup/core.py
+++ b/markup/core.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 """Core classes for markup processing."""
 
@@ -57,7 +57,7 @@
     def __init__(self, events):
         """Initialize the stream with a sequence of markup events.
         
-        @oaram events: a sequence or iterable providing the events
+        @param events: a sequence or iterable providing the events
         """
         self.events = events
 
@@ -111,7 +111,7 @@
             cls = {'xml': output.XMLSerializer,
                    'html': output.HTMLSerializer}[method]
         else:
-            assert issubclass(cls, serializers.Serializer)
+            assert issubclass(cls, output.Serializer)
         serializer = cls(**kwargs)
 
         stream = self
@@ -168,13 +168,15 @@
         If the `attrib` parameter is provided, it is expected to be a sequence
         of `(name, value)` tuples.
         """
-        list.__init__(self, map(lambda (k, v): (QName(k), v), attrib or []))
+        if attrib is None:
+            attrib = []
+        list.__init__(self, [(QName(name), value) for name, value in attrib])
 
     def __contains__(self, name):
         """Return whether the list includes an attribute with the specified
         name.
         """
-        return name in [attr for attr, value in self]
+        return name in [attr for attr, _ in self]
 
     def get(self, name, default=None):
         """Return the value of the attribute with the specified name, or the
@@ -216,10 +218,10 @@
     """
     __slots__ = []
 
-    def __new__(self, text='', *args):
+    def __new__(cls, text='', *args):
         if args:
             text %= tuple([escape(arg) for arg in args])
-        return unicode.__new__(self, text)
+        return unicode.__new__(cls, text)
 
     def __add__(self, other):
         return Markup(unicode(self) + escape(other))
@@ -257,7 +259,8 @@
                 return unichr(ref)
             else: # character entity
                 ref = match.group(2)
-                if keepxmlentities and ref in ('amp', 'apos', 'gt', 'lt', 'quot'):
+                if keepxmlentities and ref in ('amp', 'apos', 'gt', 'lt',
+                                               'quot'):
                     return '&%s;' % ref
                 try:
                     codepoint = htmlentitydefs.name2codepoint[ref]
--- a/markup/eval.py
+++ b/markup/eval.py
@@ -5,11 +5,13 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
+
+"""Support for "safe" evaluation of Python expressions."""
 
 import __builtin__
 import compiler
@@ -101,10 +103,19 @@
     __visitors = {}
 
     def __init__(self, source):
+        """Create the expression.
+        
+        @param source: the expression as string
+        """
         self.source = source
         self.ast = None
 
     def evaluate(self, data):
+        """Evaluate the expression against the given data dictionary.
+        
+        @param data: a mapping containing the data to evaluate against
+        @return: the result of the evaluation
+        """
         if not self.ast:
             self.ast = compiler.parse(self.source, 'eval')
         return self._visit(self.ast.node, data)
--- a/markup/filters.py
+++ b/markup/filters.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 """Implementation of a number of stream filters."""
 
--- a/markup/input.py
+++ b/markup/input.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 from xml.parsers import expat
 try:
--- a/markup/output.py
+++ b/markup/output.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 """This module provides different kinds of serialization methods for XML event
 streams.
--- a/markup/path.py
+++ b/markup/path.py
@@ -1,15 +1,15 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2006 Edgewall Software
+# Copyright (C) 2006 Christopher Lenz
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 """Basic support for evaluating XPath expressions against streams."""
 
--- a/markup/plugin.py
+++ b/markup/plugin.py
@@ -1,15 +1,16 @@
 # -*- coding: utf-8 -*-
 #
 # Copyright (C) 2006 Matthew Good
+# Copyright (C) 2006 Christopher Lenz
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import os
 from pkg_resources import resource_filename
--- a/markup/template.py
+++ b/markup/template.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 """Template engine that is compatible with Kid (http://kid.lesscode.org) to a
 certain extent.
--- a/markup/tests/__init__.py
+++ b/markup/tests/__init__.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import doctest
 import unittest
--- a/markup/tests/builder.py
+++ b/markup/tests/builder.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import doctest
 from HTMLParser import HTMLParseError
--- a/markup/tests/core.py
+++ b/markup/tests/core.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import doctest
 import unittest
--- a/markup/tests/eval.py
+++ b/markup/tests/eval.py
@@ -5,21 +5,20 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at hhttp://markup.cmlenz.net/log/.
 
 import doctest
 import unittest
 
-from markup import eval
-
+from markup.eval import Expression
 
 def suite():
     suite = unittest.TestSuite()
-    suite.addTest(doctest.DocTestSuite(eval))
+    suite.addTest(doctest.DocTestSuite(Expression.__module__))
     return suite
 
 if __name__ == '__main__':
--- a/markup/tests/input.py
+++ b/markup/tests/input.py
@@ -1,15 +1,15 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2006 Edgewall Software
+# Copyright (C) 2006 Christopher Lenz
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import doctest
 import unittest
--- a/markup/tests/output.py
+++ b/markup/tests/output.py
@@ -1,15 +1,15 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2006 Edgewall Software
+# Copyright (C) 2006 Christopher Lenz
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import doctest
 import unittest
--- a/markup/tests/path.py
+++ b/markup/tests/path.py
@@ -5,11 +5,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import doctest
 import unittest
--- a/markup/tests/template.py
+++ b/markup/tests/template.py
@@ -1,15 +1,15 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2006 Edgewall Software
+# Copyright (C) 2006 Christopher Lenz
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 import doctest
 import unittest
--- a/setup.py
+++ b/setup.py
@@ -6,11 +6,11 @@
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
-# are also available at http://trac.edgewall.com/license.html.
+# are also available at http://markup.cmlenz.net/wiki/License.
 #
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
-# history and logs, available at http://projects.edgewall.com/trac/.
+# history and logs, available at http://markup.cmlenz.net/log/.
 
 from setuptools import setup, find_packages
 
Copyright (C) 2012-2017 Edgewall Software