Commits

Jonathan Eunice committed f1e8924

reorganized package; tested under PyPy; fixed 2.6 limitation

Comments (0)

Files changed (10)

     print "'bozo' mentioned", c.bozo, "times"
     print c
     
-**NB** ``counterstuf`` does not yet function under Python 2.6, since it
-does not have a ``collections.Counter``. It doesn't have a ``ChainMap``,
-either, but we have a workaround for that (piggyback ``stuf.ChainMap``).
-Will have to acquire a suitable ``Counter`` workaround for 2.6.
-
 Notes
 =====
 
    and `tox <http://pypi.python.org/pypi/tox>`_.
    
  * Now
-   successfully packaged for, and tested against, Python 2.6, 2.7, 3.2, and 3.3.
-   (With the exception of ``counterstuf`` under 2.6, as described above.)
+   successfully packaged and tested for Python 2.6, 2.7, 3.2, 3.3 and
+   PyPy 1.9. Previous exceptions for Python 2.6 have been eliminated.
  
  * The author, `Jonathan Eunice <mailto:jonathan.eunice@gmail.com>`_ or
    `@jeunice on Twitter <http://twitter.com/jeunice>`_
 
     python3.3 -m easy_install otherstuf
     
-(You may need to prefix these with "sudo " to authorize installation.)
+(You may need to prefix these with "sudo " to authorize installation. If they're
+already installed, the ``--upgrade`` flag will be helpful; add it right before the
+package name.)

__init__.py

-from chainstuf import *
-from counterstuf import *

chainstuf.py

-"""
-Sidecar to `stuf` that adds `ChainMap`-like 
-container `chainstuf`
-"""
-
-from stuf.collects import ChainMap
-
-class chainstuf(ChainMap):
-    """
-    A stuf-like surfacing of the ChainMap collection
-    (multi-layer dict) introduced in Python 3. Uses a
-    workalike replacement under Python 2.
-    """
-    def __init__(self, *maps):
-        ChainMap.__init__(self, *maps)
-        
-    def __getattr__(self, key):
-        # handle normal object attributes
-        if key in self.__dict__:
-            return self.__dict__[key]
-        # handle special attributes
-        else:
-            for m in self.maps:
-                try:
-                    return m[key]
-                except KeyError:
-                    pass
-            raise KeyError(key)
-    
-    def __setattr__(self, key, value):
-        # handle normal object attributes
-        if key == 'maps' or key in self.__dict__:
-            ChainMap.__setattr__(self, key, value)
-        else:
-            self.maps[0][key] = value

counterstuf.py

-"""
-Sidecar to `stuf` that adds `Counter`-like 
-container `counterstuf`
-"""
-
-from collections import Counter
-
-class counterstuf(Counter):
-    """stuf-like surfacing of Counter"""
-    
-    def __getattr__(self, key):
-        if key in self.__dict__:
-            return self.__dict__[key]
-        else:
-            return self[key]
-
-    def __setattr__(self, key, value):
-        if key in self.__dict__:
-            self.__dict__[key] = value
-        else:
-            self[key] = value
-        
-    def update_self(self, *args, **kwargs):
-        self.update(*args, **kwargs)
-        return self
-    
-    def copy(self):
-        return counterstuf(Counter.copy(self))

otherstuf/__init__.py

+
+from otherstuf.chainstuf import chainstuf
+from otherstuf.counterstuf import counterstuf

otherstuf/chainstuf.py

+"""
+Sidecar to `stuf` that adds `ChainMap`-like 
+container `chainstuf`
+"""
+
+try:
+    from collections import ChainMap
+except ImportError:
+    from stuf.collects import ChainMap
+
+
+class chainstuf(ChainMap):
+    """
+    A stuf-like surfacing of the ChainMap collection
+    (multi-layer dict) introduced in Python 3. Uses a
+    workalike replacement under Python 2.
+    """
+    def __init__(self, *maps):
+        ChainMap.__init__(self, *maps)
+        
+    def __getattr__(self, key):
+        # handle normal object attributes
+        if key in self.__dict__:
+            return self.__dict__[key]
+        # handle special attributes
+        else:
+            for m in self.maps:
+                try:
+                    return m[key]
+                except KeyError:
+                    pass
+            raise KeyError(key)
+    
+    def __setattr__(self, key, value):
+        # handle normal object attributes
+        if key == 'maps' or key in self.__dict__:
+            ChainMap.__setattr__(self, key, value)
+        else:
+            self.maps[0][key] = value

otherstuf/counterstuf.py

+"""
+Sidecar to `stuf` that adds `Counter`-like 
+container `counterstuf`
+"""
+try:
+    from collections import Counter
+except ImportError:
+    from stuf.collects import Counter
+
+class counterstuf(Counter):
+    """stuf-like surfacing of Counter"""
+    
+    def __getattr__(self, key):
+        if key in self.__dict__:
+            return self.__dict__[key]
+        else:
+            return self[key]
+
+    def __setattr__(self, key, value):
+        if key in self.__dict__:
+            self.__dict__[key] = value
+        else:
+            self[key] = value
+        
+    def update_self(self, *args, **kwargs):
+        self.update(*args, **kwargs)
+        return self
+    
+    def copy(self):
+        return counterstuf(Counter.copy(self))
 
 setup(
     name='otherstuf',
-    version=verno("0.65"),
+    version=verno("0.701"),
     author='Jonathan Eunice',
     author_email='jonathan.eunice@gmail.com',
     description='Attributes-accessible mappings chainstuf (like ChainMap) & counterstuf (like Counter)',
     long_description=open('README.rst').read(),
     url='https://bitbucket.org/jeunice/otherstuf',
-    py_modules=['counterstuf', 'chainstuf'],
-    install_requires=['stuf>=0.9.9'],
+    packages=['otherstuf'],
+    install_requires=['stuf>=0.9.10'],
     tests_require = ['tox', 'pytest'],
     zip_safe = True,
-    keywords='Counter Chainmap stuf attribute mapping',
+    keywords='Counter ChainMap stuf attribute mapping nested',
     classifiers=linelist("""
-        Development Status :: 3 - Alpha
+        Development Status :: 4 - Beta
         Operating System :: OS Independent
         License :: OSI Approved :: BSD License
         Intended Audience :: Developers
 
-from chainstuf import *
-from counterstuf import *
+from otherstuf import *
 
 def test_chainstuf():
     """Test chainstuf class"""
 [tox]
-envlist = py26, py27, py32, py33
+envlist = py26, py27, py32, py33, pypy
 
 [testenv]
 changedir=test