Commits

Lynn Rees committed eef2241

- fixes

Comments (0)

Files changed (2)

 # -*- coding: utf-8 -*-
-'''
-XML templates.
-'''
+'''XML templates.'''
 
 import md5 as _md5
 import random as _random
 
 
 def _copytree(tree):
-    '''
-    Copies an element.
-    '''
+    # copies an element.
     element = tree.makeelement(tree.tag, tree.attrib)
     element.tail, element.text = tree.tail, tree.text
     eappend = element.append
 
 
 def _copyetree(tree, builder):
-    '''
-    Copies an element to a different ElementTree implementation.
-    '''
+    # copies an element to a different ElementTree implementation.
     element = builder(tree.tag, dict(items(tree.attrib)))
     element.tail, element.text = tree.tail, tree.text
     eappend = element.append
 
 class _XMLMany(object):
 
-    '''
-    Base class for XML template with sub-templates.
-    '''
+    '''Base class for XML template with sub-templates.'''
 
     # XML attribute indicating fields and groups
     _mark = 'id'
 
 class _XMLOne(_Field, _NonRoot):
 
-    '''
-    Base XML template field.
-    '''
+    '''Base XML template field.'''
 
     # attribute indicating fields
     _mark = 'id'
         return super(_XMLOne, self).__imod__(data)
 
     def __getitem__(self, key):
-        '''
-        Returns the attribute with the given key.
-        '''
+        '''Returns the attribute with the given key.'''
         return self._attrib[key]
 
     def __setitem__(self, key, value):
-        '''
-        Sets the XML attribute at the given key.
-        '''
+        '''Sets the XML attribute at the given key.'''
         # set attribute property if automagic on
         if hasattr(self, key):
             setattr(self, key, value)
             self._setattr(key, value)
 
     def __delitem__(self, key):
-        '''
-        Deletes an XML attribute.
-        '''
+        '''Deletes an XML attribute.'''
         # delete the property if automagic on
         try:
             delattr(self, _checkname(key))
             pass
 
     def __contains__(self, key):
-        '''
-        If an XML attribute is in a field.
-        '''
+        '''If an XML attribute is in a field.'''
         return key in self._attrib
 
     def __len__(self):
-        '''
-        Number of XML attributes in a field.
-        '''
+        '''Number of XML attributes in a field.'''
         return len(self._attrib)
 
     def __iter__(self):
-        '''
-        Iterate over internal XML attribute :class:`dict`.
-        '''
+        '''Iterate over internal XML attribute :class:`dict`.'''
         return iter(self._attrib)
 
     def _delmark(self):
 
     @property
     def current(self):
-        '''
-        Returns the current state of self.
-        '''
+        '''Returns the current state of self.'''
         return self._getcurrent(
             self._field, template=self._template, tattrib=self._tattrib,
         )
 
     @property
     def default(self):
-        '''
-        Returns the default state of self.
-        '''
+        '''Returns the default state of self.'''
         return self._getdefault(
             self._field, template=self._template, tattrib=self._tattrib,
         )
             delitem(item)
 
     def reset(self, **kw):
-        '''
-        Return :class:`template` object to its default state.
-        '''
+        '''Return :class:`template` object to its default state.'''
         super(_XMLOne, self).reset(
             template=self._template, tattrib=self._tattrib,
         )
 
 class _XMLField(object):
 
-    '''
-    Dispatcher for XML template fields.
-    '''
+    '''Dispatcher for XML template fields.'''
 
     _group, _klass = None, _XMLOne
 
 
 class _XMLGroup(_XMLMany, _Group, _NonRoot):
 
-    '''
-    XML group template.
-    '''
+    '''XML group template.'''
 
     _field = _XMLField
 
 
     @property
     def current(self):
-        '''
-        Property that returns the current state of this group.
-        '''
+        '''Current state of this group.'''
         return self._getcurrent(_XMLGroup, templates=self._templates)
 
     @property
     def default(self):
-        '''
-        Property that returns the default state of this group.
-        '''
+        '''Default state of this group.'''
         return self._getdefault(_XMLGroup, templates=self._templates)
 
     def reset(self, **kw):
-        '''
-        Resets a group back to its default state.
-        '''
+        '''Resets group back to its default state. '''
         super(_XMLGroup, self).reset(templates=self._templates)
 
 
                 field.groupmark = mark
 
     def _setxslt(self, stylesheet):
-        '''
-        Sets the XSLT stylesheet for a template.
-        '''
+        '''Sets XSLT stylesheet for template.'''
         self._xslt = XSLT(XML(stylesheet))
 
     def transform(self, stylesheet=None, **kw):
         '''
-        Transforms a template based on an XSLT stylesheet.
+        Transforms template based on XSLT stylesheet.
 
         :keyword str stylesheet: XSLT document
         :param kw: keyword arguments
         return u(self._xslt(self._tree, **kw))
 
     def xinclude(self):
-        '''
-        Processes any xinclude statements in the internal template.
-        '''
+        '''Processes xinclude statements in template.'''
         ElementTree(self._tree).xinclude()
 
     def fromfile(self, path):
         '''
-        Creates an internal element from a file source.
+        Creates element from file source.
 
         :argument str path: path to template source
         '''
 
     def fromstring(self, instring):
         '''
-        Creates an internal element from a :class:`str` source.
+        Creates element from :class:`str` source.
 
         :argument str instring: :class:`str` source for internal element
         '''
 
     def render(self, info=None, format='xml'):
         '''
-        :class:`str` version of the internal element.
+        :class:`str` version of element.
 
         :keyword info: data to substitute into an XML document
         :keyword str format: format of document
         return xtostring(self._tree)
 
     def reset(self):
-        '''
-        Return a :class:`template` to its default state.
-        '''
+        '''Return template to its default state.'''
         self.__init__(
             self._btree, self._auto, self._max, templates=self._templates
         )
 
 class HTMLTemplate(Template):
 
-    '''
-    HTML template.
-    '''
+    '''HTML template.'''
 
     def fromfile(self, path):
         '''
-        Creates an internal element from a file source.
+        Load template from file source.
 
-        :param str path: path to a template source
+        :param str path: path to template
         '''
         # try ordinary XML parsing
         try:
 
     def fromstring(self, instring):
         '''
-        Creates an internal element from a source.
+        Load template from string.
 
         :argument str path: source for internal template
         '''
 
     def render(self, info=None, format='html', encoding='unicode'):
         '''
-        A string version of the internal element's parent.
+        Render string from template.
 
         :keyword info: data to substitute into a document
         :keyword str format: HTML doctype to use for string
 
     def write(self, path, info=None, format='html', encoding='unicode'):
         '''
-        Write template results to file.
+        Write rendered template to file.
 
         :argument str path: path of destination file
         :keyword info: data to substitute into a document
 Template engine where Python is the template language.
 '''
 
-__version__ = (0, 5, 0)
+__version__ = (0, 6, 0)