Lynn Rees avatar Lynn Rees committed 931dcc8

- local configuration

Comments (0)

Files changed (9)

 # -*- coding: utf-8 -*-
 '''stage fabfile'''
 
-from fabric.api import prompt, local, settings, env, lcd
+from fabric.api import prompt, local, settings, env
 
 regup = './setup.py register sdist --format=bztar,zip upload'
 nodist = 'rm -rf dist'
-#sphinxup = './setup.py upload_sphinx'
 
 
 def getversion(fname):
 
 
 def _test(val):
-    truth = val in ['py26', 'py27', 'py31', 'py32']
+    truth = val in ['py26', 'py27', 'py31', 'py32', 'py33', 'pypy']
     if truth is False:
         raise KeyError(val)
     return val
 
 
-def tox():
-    '''test stage'''
-    local('tox')
-
-
-def docs():
-    with lcd('docs/'):
-        local('make clean')
-        local('make html')
-        local('make linkcheck')
-        local('make doctest')
-
-
-def update_docs():
-    docs()
-    with settings(warn_only=True):
-        local('hg ci -m docmerge')
-        local('hg push ssh://hg@bitbucket.org/lcrees/stage')
-        local('hg push github')
-#    local(sphinxup)
-
-
 def tox_recreate():
     '''recreate stage test env'''
     prompt(
-        'Enter testenv: [py26, py27, py31, py32]',
+        'Enter testenv: [py26, py27, py31, py32, py33, pypy]',
         'testenv',
         validate=_test,
     )
     local('tox --recreate -e %(testenv)s' % env)
 
 
-def release():
-    '''release stage'''
-#    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')
+def releaser():
+    '''stage releaser'''
     _promptup()
     local(regup)
-#    local(sphinxup)
-    local(nodist)
-
-
-def releaser():
-    '''stage releaser'''
-#    docs()
-    _promptup()
-    local(regup)
-#    local(sphinxup)
     local(nodist)
 
 
 def inplace():
     '''in-place stage'''
-#    docs()
     with settings(warn_only=True):
         local('hg push ssh://hg@bitbucket.org/lcrees/stage')
         local('hg push github')
     local('./setup.py sdist --format=gztar,zip upload')
-#    local(sphinxup)
     local(nodist)

reqs/requires-2.6.txt

 importlib
 parse>=1.5.1
 stuf==0.9.6
-knife==0.5.10
+knife==0.5.11

reqs/requires.txt

 parse>=1.5.1
 stuf==0.9.6
-knife==0.5.10
+knife==0.5.11
-[build_sphinx]
-source-dir = docs
-build-dir = docs/_build
-all_files = 1
-
-[upload_sphinx]
-upload-dir = docs/_build/html
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3.1',
         'Programming Language :: Python :: 3.2',
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: Implementation :: CPython',
+        'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Software Development',
         'Topic :: Software Development :: Libraries',
     ],

stage/__init__.py

 # -*- coding: utf-8 -*-
 '''Pythonic configuration.'''
 
-from .conf import Context, Conf, Env, env, context, With
+from .conf import Context, Conf, Env, env, context, With, localconf
 
-__all__ = 'Context Conf Env env context With'.split()
-__version__ = (0, 2, 1)
+__all__ = 'Context Conf Env env context With localconf'.split()
+__version__ = (0, 2, 2)
 _CONF_SLOTS = '_conf _this _current'.split()
 
 
+def localconf(this, attribute='Meta', *args, **kw):
+    '''
+    Load local configuration from `attribute` on `this` class and its base
+    classes (plus any custom configuration).
+    '''
+    return (lazyknife(this).mro().attrs(attribute).traverse().attrs('maps')
+    .merge().params(*args, **kw).invoke('update').reverse().mapping()
+    .wrap(frozenstuf).get())
+
+
 class _BaseFactory(object):
 
     '''Base configuration factory.'''
         self._conf = envz = environ
         if conf is not None:
             dumps = pickle.dumps
+            b64enc = b64encode
             # populate os.environ
             for k, v in items(conf):
                 for x, y in items(v):
-                    envz[join((k, x))] = b64encode(dumps(y)).decode('utf-8')
+                    envz[join((k, x))] = b64enc(dumps(y)).decode('utf-8')
 
     def __enter__(self):
         # make default key

tests/test_stage.py

     def setUp(self):
         self.defaults = 'tests.twodeep.defaults'
         self.required = 'tests.twodeep.required'
+
+
+class TestLocalConf(unittest.TestCase):
+
+    def test_local_conf(self):
+        from stage.conf import localconf
+
+        class Foo(object):
+            class Meta:
+                # anchor link label
+                anchor_link = ''
+                fork_link = ''
+                fts_index = ''
+                index = ''
+                reference_link = ''
+                root_index = 'roots'
+                slug_field = ''
+                version_link = ''
+                versioned = False
+
+        class Bar(Foo):
+
+            class Meta:
+                fork_link = 'BAR_OF'
+                fts_index = 'bar_text'
+                index = 'cons'
+                reference_link = 'BAR_NODE_OF'
+                slug_field = 'slug'
+                version_link = 'BAR_VERSION_OF'
+                versioned = False
+
+        class FooBar(Bar):
+
+            class Meta:
+                index = 'bar'
+                anchor_link = 'foo'
+                reference_link = 'FORK_NODE_OF'
+                versioned = True
+
+        this = localconf(FooBar)
+        self.assertEqual(this.root_index, 'roots')
+        self.assertTrue(this.versioned)
+        self.assertEqual(this.index, 'bar')
+        self.assertEqual(this.anchor_link,  'foo')
+        self.assertEqual(this.fork_link,  'BAR_OF')
+        self.assertEqual(this.fts_index,  'bar_text')
+        self.assertEqual(this.reference_link,  'FORK_NODE_OF')
+        self.assertEqual(this.slug_field,  'slug')
+        self.assertEqual(this.version_link,  'BAR_VERSION_OF')
 [tox]
-envlist = py26,py27,py32,py33,pypy
+envlist = py26,py27,py31,py32,py33,pypy
 
 [testenv:py26]
 deps=
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.