# HG changeset patch # User cmlenz # Date 1151486889 0 # Node ID b4f78c05e5c9260a777d50df96699f223b1e9854 # Parent 3c1a022be04c5d2c4e2aeeed6c41cf7f775e98b9 * Fix the boilerplate in the Python source files. * Some more docstrings and cosmetic fixes. diff --git a/markup/__init__.py b/markup/__init__.py --- 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). diff --git a/markup/builder.py b/markup/builder.py --- 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 diff --git a/markup/core.py b/markup/core.py --- 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] diff --git a/markup/eval.py b/markup/eval.py --- 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) diff --git a/markup/filters.py b/markup/filters.py --- 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.""" diff --git a/markup/input.py b/markup/input.py --- 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: diff --git a/markup/output.py b/markup/output.py --- 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. diff --git a/markup/path.py b/markup/path.py --- 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.""" diff --git a/markup/plugin.py b/markup/plugin.py --- 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 diff --git a/markup/template.py b/markup/template.py --- 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. diff --git a/markup/tests/__init__.py b/markup/tests/__init__.py --- 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 diff --git a/markup/tests/builder.py b/markup/tests/builder.py --- 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 diff --git a/markup/tests/core.py b/markup/tests/core.py --- 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 diff --git a/markup/tests/eval.py b/markup/tests/eval.py --- 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__': diff --git a/markup/tests/input.py b/markup/tests/input.py --- 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 diff --git a/markup/tests/output.py b/markup/tests/output.py --- 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 diff --git a/markup/tests/path.py b/markup/tests/path.py --- 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 diff --git a/markup/tests/template.py b/markup/tests/template.py --- 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 diff --git a/setup.py b/setup.py --- 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