Commits

Lynn Rees committed d8729a9 Merge

Comments (0)

Files changed (10)

 8f5cfcf130d1a09b2351c1f0449e84a36f42ce20 0.8.15
 a87b80015785b4fbe503a2139c4eac52d1e650c3 0.8.17
 df4bb6b5e146a8c63a80988e9197de8a8a94b350 0.8.18
+7fe58be9ee74c51d6ce41bf1cac77910eb6ae9cd 0.8.19
     with settings(warn_only=True):
         local('hg tag "%(tag)s"' % env)
         local('hg push ssh://hg@bitbucket.org/lcrees/stuf')
-#        local('hg push github')
+        local('hg push github')
 
 
 def _test(val):

reqs/fabfile.py

-# -*- coding: utf-8 -*-
-'''stuf 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/stuf')
-        local('hg push github')
-
-
-def _test(val):
-    truth = val in ['py26', 'py27', 'py31', 'py32']
-    if truth is False:
-        raise KeyError(val)
-    return val
-
-
-def tox():
-    '''test stuf'''
-    with lcd('../'):
-        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/stuf')
-        local('hg push github')
-    local(sphinxup)
-
-
-def tox_recreate():
-    '''recreate stuf test env'''
-    with lcd('../'):
-        prompt(
-            'Enter testenv: [py26, py27, py31, py32]',
-            'testenv',
-            validate=_test,
-        )
-        local('tox --recreate -e %(testenv)s' % env)
-
-
-def release():
-    '''release stuf'''
-#    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():
-    '''knife releaser'''
-#    docs()
-    _promptup()
-    local(regup)
-    local(sphinxup)
-    local(nodist)
-
-
-def inplace():
-    '''in-place stuf'''
-#    docs()
-    with settings(warn_only=True):
-        local('hg push ssh://hg@bitbucket.org/lcrees/stuf')
-        local('hg push github')
-    local('../setup.py sdist --format=bztar,gztar,zip upload')
-    local(sphinxup)
-    local(nodist)
 
 setup(
     name='stuf',
-    version='0.8.18',
+    version='0.8.19',
     description='dictionaries with attribute-style access',
     long_description=open(join(getcwd(), 'README.rst'), 'r').read(),
     keywords='dict attribute collection mapping dot notation access bunch',
 from stuf.desc import lazy
 from stuf.iterable import exhaust
 from stuf.collects import OrderedDict
-from stuf.six import (
-    items, strings, keys, map, getvalues, getkeys, getitems)
 from stuf.deep import recursive_repr, clsname, getter, getcls
+from stuf.six import items, strings, map, getvalues, getitems, getkeys
 
 __all__ = ('defaultstuf', 'fixedstuf', 'frozenstuf', 'orderedstuf', 'stuf')
 
     def _classkeys(self):
         # protected keywords
         return frozenset(chain(
-            keys(vars(self)), keys(vars(getcls(self))), self._reserved,
+            iter(vars(self)), iter(vars(getcls(self))), self._reserved,
         ))
 
     @classmethod
 
     def _prepopulate(self, *args, **kw):
         iterable = super(fixedstuf, self)._prepopulate(*args, **kw)
-        self.allowed = frozenset(keys(iterable))
+        self.allowed = frozenset(iterable)
         return iterable
 
     def popitem(self):
         return (getcls(self), (_getter(self, '_wrapped')._asdict().copy(),))
 
     @classmethod
-    def _mapping(self, mapping, _namedtuple=namedtuple, _keys=keys):
-        return _namedtuple('frozenstuf', _keys(mapping))(**mapping)
+    def _mapping(self, mapping, _namedtuple=namedtuple):
+        return _namedtuple('frozenstuf', iter(mapping))(**mapping)
 
 
 class orderedstuf(writewrapstuf):
 # -*- coding: utf-8 -*-
 '''stuf descriptor utilities'''
 
-from functools import update_wrapper
+from functools import update_wrapper, partial
 
 from stuf.deep import selfname, setter
 
         return self if this is None else self._set(this)
 
 
+class lazypartial(lazy):
+
+    '''
+    Lazily assign attributes on an instance upon first use.
+    '''
+
+    def _set(self, this):
+        return setter(this, self.name, partial(*self.method(this)))
+
+
 class lazy_class(_lazyinit):
 
     '''
 from stuf.six import items, map
 
 
-def deferfunc(func):
-    '''Defer running `func`.'''
-    yield func()
+def breakcount(func, length):
+    '''
+    Run an iterator until it reaches its original length.
 
-
-def deferiter(iterator):
-    '''Defer running `iterator`.'''
-    yield next(iterator)
+    :param iterable: an iterable to exhaust
+    '''
+    while length:
+        yield func()
+        length -= 1
 
 
 def count(iterable, enumerate=enumerate, next=next, S=StopIteration):
                 return 0
 
 
+def deferfunc(func):
+    '''Defer running `func`.'''
+    yield func()
+
+
+def deferiter(iterator):
+    '''Defer running `iterator`.'''
+    yield next(iterator)
+
+
 def exhaust(iterable, exception=StopIteration, _n=next):
     '''
     Call next on an iterator until it's exhausted.
         pass
 
 
-def breakcount(func, length):
-    '''
-    Run an iterator until it reaches its original length.
-
-    :param iterable: an iterable to exhaust
-    '''
-    while length:
-        yield func()
-        length -= 1
-
-
 def exhaustmap(mapping, call, filter=None, exception=StopIteration, _n=next):
     '''
     Call `next` on an iterator until it's exhausted.
 # -*- coding: utf-8 -*-
-# pylint: disable-msg=f0401,w0613,w0631,w0622,w0122
 '''utilities for writing code that runs on Python 2 and 3'''
 
 import sys
 import types
 import operator
 try:
+    from __builtin__ import intern
     from future_builtins import filter, map, zip
+    from cPickle import loads as ld, dumps, HIGHEST_PROTOCOL
 except ImportError:
+    from sys import intern  # @UnusedImport
     from builtins import filter, map, zip  # @UnusedImport
+    from pickle import loads as ld, dumps, HIGHEST_PROTOCOL  # @UnusedImport
 try:
     import unittest2 as unittest
 except ImportError:
         from dummy_thread import get_ident
     except ImportError:
         from _thread import get_ident  # @UnusedImport
-try:
-    from __builtin__ import intern
-except ImportError:
-    from sys import intern  # @UnusedImport
-try:
-    from cPickle import loads as ld, dumps, HIGHEST_PROTOCOL
-except ImportError:
-    from pickle import loads as ld, dumps, HIGHEST_PROTOCOL  # @UnusedImport
-
-__author__ = 'Benjamin Peterson <benjamin@python.org>'
-__version__ = '1.1.0'
 
 # True if we are running on Python 3.
 PY3 = sys.version_info[0] == 3
     PY3, HIGHEST_PROTOCOL, items, isstring, function_code, ld, dumps, u, b,
     intern)
 
-
-def memoize(f, i=intern, z=items, r=repr, uw=update_wrapper):
-    '''
-    memoize function
-    '''
-    f.cache = {}.setdefault
-    if function_code(f).co_argcount == 1:
-        def memoize_(arg):
-            return f.cache(i(r(arg)), f(arg))
-    else:
-        def memoize_(*args, **kw): #@IgnorePep8
-            return f.setdefault(
-                i(r(args, z(kw)) if kw else r(args)), f(*args, **kw)
-            )
-    return uw(f, memoize_)
-
-
-if PY3:
-    loads = memoize(lambda x: ld(x, encoding='latin-1'))
-else:
-    loads = memoize(lambda x: ld(x))
+# check for None
+isnone = lambda x, y: x if y is None else y
+# import loader
+lazyload = lambda x: lazyimport(x) if isstring(x) and '.' in x else x
 
 
 def lazyimport(path, attribute=None, i=import_module, g=getattr, s=isstring):
     return decorating_function
 
 
-@memoize
+def memoize(f, i=intern, z=items, r=repr, uw=update_wrapper):
+    '''
+    memoize function
+    '''
+    f.cache = {}.setdefault
+    if function_code(f).co_argcount == 1:
+        def memoize_(arg):
+            return f.cache(i(r(arg)), f(arg))
+    else:
+        def memoize_(*args, **kw): #@IgnorePep8
+            return f.setdefault(
+                i(r(args, z(kw)) if kw else r(args)), f(*args, **kw)
+            )
+    return uw(f, memoize_)
+
+
+if PY3:
+    loads = memoize(lambda x: ld(x, encoding='latin-1'))
+else:
+    loads = memoize(lambda x: ld(x))
+
+
 def optimize(
     obj,
     d=dumps,
 # -*- coding: utf-8 -*-
 
-__version__ = (0, 8, 18)
+__version__ = (0, 8, 19)
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.