Commits

Lynn Rees  committed 204678f

- moeve

  • Participants
  • Parent commits 61db781

Comments (0)

Files changed (5)

+# -*- coding: utf-8 -*-
+'''webstring fabfile'''
+
+from fabric.api import prompt, local, settings, env, lcd
+
+regup = '../setup.py register sdist --format=bztar,gztar,zip upload'
+nodist = 'rm -rf ../dist'
+sphinxup = '../setup.py upload_sphinx'
+
+
+def _promptup():
+    prompt('Enter tag: ', 'tag')
+    with settings(warn_only=True):
+        local('hg tag "%(tag)s"' % env)
+        local('hg push ssh://hg@bitbucket.org/lcrees/webstring')
+        local('hg push github')
+
+
+def _test(val):
+    truth = val in ['py26', 'py27', 'py31', 'py32', 'pypy']
+    if truth is False:
+        raise KeyError(val)
+    return val
+
+
+def docs():
+    with lcd('../docs/'):
+        local('make clean')
+        local('make html')
+        local('make linkcheck')
+        local('make doctest')
+
+
+def tox():
+    '''
+    test webstring
+    '''
+    with lcd('../'):
+        local('tox')
+
+
+def update_docs():
+    '''
+    update webstring docs
+    '''
+    docs()
+    with settings(warn_only=True):
+        local('hg ci -m docmerge')
+        local('hg push ssh://hg@bitbucket.org/lcrees/webstring')
+        local('hg push github')
+    local(sphinxup)
+
+
+def tox_recreate():
+    '''
+    recreate webstring test env
+    '''
+    with lcd('../'):
+        prompt(
+            'Enter testenv: [py26, py27, py31, py32, pypy]',
+            'testenv',
+            validate=_test,
+        )
+        local('tox --recreate -e %(testenv)s' % env)
+
+
+def release():
+    '''
+    release webstring
+    '''
+    docs()
+    local('hg update pu')
+    local('hg update next')
+    local('hg merge pu; hg ci -m automerge')
+    local('hg update maint')
+    local('hg merge default; hg ci -m automerge')
+    local('hg update default')
+    local('hg merge next; hg ci -m automerge')
+    local('hg update pu')
+    local('hg merge default; hg ci -m automerge')
+    _promptup()
+    local(regup)
+    local(sphinxup)
+    local(nodist)
+
+
+def releaser():
+    '''
+    webstring releaser
+    '''
+    docs()
+    _promptup()
+    local(regup)
+    local(sphinxup)
+    local(nodist)
+
+
+def inplace():
+    '''
+    in-place webstring
+    '''
+    docs()
+    with settings(warn_only=True):
+        local('hg push ssh://hg@bitbucket.org/lcrees/webstring')
+        local('hg push github')
+    local('../setup.py sdist --format=bztar,gztar,zip upload')
+    local(sphinxup)
+    local(nodist)
+
+
+def release_next():
+    '''
+    release webstring from next branch
+    '''
+    docs()
+    local('hg update maint')
+    local('hg merge default; hg ci -m automerge')
+    local('hg update default')
+    local('hg merge next; hg ci -m automerge')
+    local('hg update next')
+    local('hg merge default; hg ci -m automerge')
+    _promptup()
+    local(regup)
+    local(sphinxup)
+    local(nodist)

File reqs/fabfile.py

-# -*- coding: utf-8 -*-
-'''webstring fabfile'''
-
-from fabric.api import prompt, local, settings, env, lcd
-
-regup = '../setup.py register sdist --format=bztar,gztar,zip upload'
-nodist = 'rm -rf ../dist'
-sphinxup = '../setup.py upload_sphinx'
-
-
-def _promptup():
-    prompt('Enter tag: ', 'tag')
-    with settings(warn_only=True):
-        local('hg tag "%(tag)s"' % env)
-        local('hg push ssh://hg@bitbucket.org/lcrees/webstring')
-        local('hg push github')
-
-
-def _test(val):
-    truth = val in ['py26', 'py27', 'py31', 'py32', 'pypy']
-    if truth is False:
-        raise KeyError(val)
-    return val
-
-
-def docs():
-    with lcd('../docs/'):
-        local('make clean')
-        local('make html')
-        local('make linkcheck')
-        local('make doctest')
-
-
-def tox():
-    '''
-    test webstring
-    '''
-    with lcd('../'):
-        local('tox')
-
-
-def update_docs():
-    '''
-    update webstring docs
-    '''
-    docs()
-    with settings(warn_only=True):
-        local('hg ci -m docmerge')
-        local('hg push ssh://hg@bitbucket.org/lcrees/webstring')
-        local('hg push github')
-    local(sphinxup)
-
-
-def tox_recreate():
-    '''
-    recreate webstring test env
-    '''
-    with lcd('../'):
-        prompt(
-            'Enter testenv: [py26, py27, py31, py32, pypy]',
-            'testenv',
-            validate=_test,
-        )
-        local('tox --recreate -e %(testenv)s' % env)
-
-
-def release():
-    '''
-    release webstring
-    '''
-    docs()
-    local('hg update pu')
-    local('hg update next')
-    local('hg merge pu; hg ci -m automerge')
-    local('hg update maint')
-    local('hg merge default; hg ci -m automerge')
-    local('hg update default')
-    local('hg merge next; hg ci -m automerge')
-    local('hg update pu')
-    local('hg merge default; hg ci -m automerge')
-    _promptup()
-    local(regup)
-    local(sphinxup)
-    local(nodist)
-
-
-def releaser():
-    '''
-    webstring releaser
-    '''
-    docs()
-    _promptup()
-    local(regup)
-    local(sphinxup)
-    local(nodist)
-
-
-def inplace():
-    '''
-    in-place webstring
-    '''
-    docs()
-    with settings(warn_only=True):
-        local('hg push ssh://hg@bitbucket.org/lcrees/webstring')
-        local('hg push github')
-    local('../setup.py sdist --format=bztar,gztar,zip upload')
-    local(sphinxup)
-    local(nodist)
-
-
-def release_next():
-    '''
-    release webstring from next branch
-    '''
-    docs()
-    local('hg update maint')
-    local('hg merge default; hg ci -m automerge')
-    local('hg update default')
-    local('hg merge next; hg ci -m automerge')
-    local('hg update next')
-    local('hg merge default; hg ci -m automerge')
-    _promptup()
-    local(regup)
-    local(sphinxup)
-    local(nodist)

File tests/test_text.py

 from webstring import TextTemplate
 
 
-class Testwebstring(unittest.TestCase):
+class TestTextString(unittest.TestCase):
 
     '''Test class for webstring text template'''
 

File webstring/base.py

     '''
 
     def __init__(self, auto, **kw):
-        # controls if templates become object attrs of a root/group Template
+        # controls if templates become object attrs of a root/group template
         self._auto = auto
 
     def __repr__(self):
     Base for Templates with subtemplates (groups or fields).
     '''
 
-    def __init__(self, auto, omax, **kw):
+    def __init__(self, auto, maxlen, **kw):
         super(_Many, self).__init__(auto, **kw)
         # sets maximum allowed repetitions of a template
-        self._max = omax
+        self._max = maxlen
         # internal tracking structures
         self._fielddict, self._fields, self._filter = dict(), list(), set()
 
         # set group delimiter.
         self._groupmark = mark
 
-    def _setmax(self, omax):
+    def _setmax(self, maxlen):
         '''
         Sets the maximum repetition value for all Templates.
         '''
         # set group or root to max
-        self._max = omax
+        self._max = maxlen
         # set max on all children
         for field in self._fields:
-            field.max = omax
+            field.max = maxlen
 
     # property for setting a maximum repetition value
     max = property(lambda self: self._max, _setmax)
     Field base.
     '''
 
-    def __init__(self, auto, omax, **kw):
+    def __init__(self, auto, maxlen, **kw):
         super(_Field, self).__init__(auto, **kw)
         # maximum repetition value and internal trackers
-        self.max, self._siblings = omax, kw.get('siblings', list())
+        self.max, self._siblings = maxlen, kw.get('siblings', list())
         self._tempfields = kw.get('tempfields', list())
 
     def __imod__(self, data):
     Group base.
     '''
 
-    def __init__(self, auto, omax, **kw):
-        super(_Group, self).__init__(auto, omax, **kw)
+    def __init__(self, auto, maxlen, **kw):
+        super(_Group, self).__init__(auto, maxlen, **kw)
         # Internal trackers
         self._siblings = kw.get('siblings', list())
         self._tempfields = kw.get('tempfields', list())
     Root template base.
     '''
 
-    def __init__(self, auto, omax, **kw):
-        super(_Template, self).__init__(auto, omax, **kw)
+    def __init__(self, auto, maxlen, **kw):
+        super(_Template, self).__init__(auto, maxlen, **kw)
 
     def append(self, data):
         '''

File webstring/markup.py

     # attribute indicating fields
     _mark = 'id'
 
-    def __init__(self, src, parent=None, auto=True, omax=25, **kw):
+    def __init__(self, src, parent=None, auto=True, maxlen=25, **kw):
         '''
         :argument src: element source
         :keyword parent: parent element of the source
         :keyword bool auto: turns automagic on and off
-        :keyword int omax: maximum number of times a field can repeat
+        :keyword int maxlen: maximum number of times a field can repeat
         '''
-        super(_XMLOne, self).__init__(auto, omax, **kw)
+        super(_XMLOne, self).__init__(auto, maxlen, **kw)
         self._group = _XMLGroup
         # parent and inline text template
         self._parent, self._template = parent, kw.get('template')
 
     _field = _XMLField
 
-    def __init__(self, src=None, parent=None, auto=True, omax=25, **kw):
+    def __init__(self, src=None, parent=None, auto=True, maxlen=25, **kw):
         '''
         :keyword src: element source
         :keyword parent: parent element of the source
         :keyword bool auto: turns automagic on and off
-        :keyword int omax: maximum number of times a field can repeat
+        :keyword int maxlen: maximum number of times a field can repeat
         '''
-        super(_XMLGroup, self).__init__(auto, omax, **kw)
+        super(_XMLGroup, self).__init__(auto, maxlen, **kw)
         self._parent = parent
         if hasattr(src, 'tag'):
             self._setelement(src)
     _group = _XMLGroup
     _parent = None
 
-    def __init__(self, src=None, auto=True, omax=25, **kw):
+    def __init__(self, src=None, auto=True, maxlen=25, **kw):
         '''
         :keyword src: path, string, or element source
         :keyword bool auto: turns automagic on or off
-        :keyword int omax: maximum number of times a template can repeat
+        :keyword int maxlen: maximum number of times a template can repeat
         '''
-        super(Template, self).__init__(auto, omax, **kw)
+        super(Template, self).__init__(auto, maxlen, **kw)
         # process element if source is an element
         if hasattr(src, 'tag'):
             self._setelement(src)
 
     def write(self, path, info=None, format='html', encoding='unicode'):
         '''
-        Writes the string of an internal element to a file.
+        Write template results to file.
 
         :argument str path: path of destination file
         :keyword info: data to substitute into a document