otherstuf-1.1.0/0000755000000000000240000000000012565162056013630 5ustar rootstaff00000000000000otherstuf-1.1.0/otherstuf/0000755000000000000240000000000012565162056015653 5ustar rootstaff00000000000000otherstuf-1.1.0/otherstuf/__init__.py0000644000076500000240000000014712565160214020441 0ustar jeunicestaff00000000000000 from .chainstuf import chainstuf from .counterstuf import counterstuf from .version import __version__otherstuf-1.1.0/otherstuf/chainstuf.py0000644000076500000240000000153512565160452020674 0ustar jeunicestaff00000000000000""" 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): 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-1.1.0/otherstuf/counterstuf.py0000644000076500000240000000103212565161266021265 0ustar jeunicestaff00000000000000""" 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): return self[key] def __setattr__(self, key, value): self[key] = value def update_self(self, *args, **kwargs): self.update(*args, **kwargs) return self def copy(self): return counterstuf(Counter.copy(self)) otherstuf-1.1.0/otherstuf/version.py0000644000076500000240000000002612565162051020364 0ustar jeunicestaff00000000000000__version__ = '1.1.0' otherstuf-1.1.0/otherstuf.egg-info/0000755000000000000240000000000012565162056017345 5ustar rootstaff00000000000000otherstuf-1.1.0/otherstuf.egg-info/dependency_links.txt0000644000000000000240000000000112565162055023412 0ustar rootstaff00000000000000 otherstuf-1.1.0/otherstuf.egg-info/not-zip-safe0000644000000000000240000000000112563134773021576 0ustar rootstaff00000000000000 otherstuf-1.1.0/otherstuf.egg-info/PKG-INFO0000644000000000000240000001441412565162055020445 0ustar rootstaff00000000000000Metadata-Version: 1.1 Name: otherstuf Version: 1.1.0 Summary: Attributes-accessible mappings chainstuf (like ChainMap) & counterstuf (like Counter) Home-page: https://bitbucket.org/jeunice/otherstuf Author: Jonathan Eunice Author-email: jonathan.eunice@gmail.com License: Apache License 2.0 Description: | |version| |downloads| |versions| |impls| |wheel| |coverage| .. |version| image:: http://img.shields.io/pypi/v/otherstuf.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/otherstuf .. |downloads| image:: http://img.shields.io/pypi/dm/otherstuf.svg?style=flat :alt: PyPI Package monthly downloads :target: https://pypi.python.org/pypi/otherstuf .. |versions| image:: https://img.shields.io/pypi/pyversions/otherstuf.svg :alt: Supported versions :target: https://pypi.python.org/pypi/otherstuf .. |impls| image:: https://img.shields.io/pypi/implementation/otherstuf.svg :alt: Supported implementations :target: https://pypi.python.org/pypi/otherstuf .. |wheel| image:: https://img.shields.io/pypi/wheel/otherstuf.svg :alt: Wheel packaging support :target: https://pypi.python.org/pypi/otherstuf .. |coverage| image:: https://img.shields.io/badge/test_coverage-100%25-6600CC.svg :alt: Test line coverage :target: https://pypi.python.org/pypi/otherstuf Attribute-accesible collections inspired by `stuf `_. Implements ``chainstuf`` and ``counterstuf``: versions of ``ChainMap`` and ``Counter`` that expose their keys as attributes. The ultimate goal of this module is to have these functions available in the ``stuf`` module, and this sidecar to be retired. Usage ===== Use these just like you would ``ChainMap`` and ``Counter``, except that you get attribute-style access as well. For ``chainstuf``:: from otherstuf import chainstuf d1 = dict(this=1, that=2) d2 = dict(roger=99, that=100) # test simple attribute equivalence c = chainstuf(d1, d2) assert c.this == 1 assert c.roger == 99 c.roger = 'wilco' assert c.roger print "roger", c.roger d1.update(feeling='fancypants!') print "i'm feeling", c.feeling # passed through, since d2 lacks 'feeling' Given recent versions (e.g. beyond 0.9.10) of ``stuf``, one could simply use ``from stuf import chainstuf``. This portion of the ``otherstuf`` sidecar is now superfluous. For ``counterstuf``:: from otherstuf import counterstuf c = counterstuf() c.update("this and this is this but that isn't this".split()) c.total = sum(c.values()) print "everything:", c.total print "'this' mentioned", c.this, "times" print "'bozo' mentioned", c.bozo, "times" print c Notes ===== * Version 1.1.0 initates automated test coverage metrics. Test coverage started at 88%. Cleanups got coverage to 100%. *Hooah!* * Automated multi-version testing managed with `pytest `_, `pytest-cov `_, `coverage `_ and `tox `_. Packaging linting with `pyroma `_. Successfully packaged for, and tested against, all late-model versions of Python: 2.6, 2.7, 3.2, 3.3, 3.4, and 3.5 pre-release (3.5.0b3) as well as PyPy 2.6.0 (based on 2.7.9) and PyPy3 2.4.0 (based on 3.2.5). Test line coverage 100%. * As of 1.0.0, updated to use semantic versioning and the Apache Software License. * Recent builds of ``stuf`` have left Python 2.6 out in the cold. This package requires ``stuf==0.9.14`` for 2.6--the last version to successfully install there. Newer Python releases will get ``stuf>=0.9.16``. I've submitted a patch for 2.6 installability to carry forward; we'll have to see where that goes. * The author, `Jonathan Eunice `_ or `@jeunice on Twitter `_ welcomes your comments and suggestions. Installation ============ To install or upgrade to the latest version:: pip install -U otherstuf To ``easy_install`` under a specific Python version (3.3 in this example):: python3.3 -m easy_install --upgrade otherstuf (You may need to prefix these with ``sudo`` to authorize installation. In environments without super-user privileges, you may want to use ``pip``'s ``--user`` option, to install only for a single user, rather than system-wide.) Keywords: Counter ChainMap stuf attribute mapping nested Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: Apache Software License Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries :: Python Modules otherstuf-1.1.0/otherstuf.egg-info/requires.txt0000644000000000000240000000001512565162055021740 0ustar rootstaff00000000000000stuf>=0.9.16 otherstuf-1.1.0/otherstuf.egg-info/SOURCES.txt0000644000000000000240000000047712565162056021241 0ustar rootstaff00000000000000README.rst setup.py otherstuf/__init__.py otherstuf/chainstuf.py otherstuf/counterstuf.py otherstuf/version.py otherstuf.egg-info/PKG-INFO otherstuf.egg-info/SOURCES.txt otherstuf.egg-info/dependency_links.txt otherstuf.egg-info/not-zip-safe otherstuf.egg-info/requires.txt otherstuf.egg-info/top_level.txt test/test.pyotherstuf-1.1.0/otherstuf.egg-info/top_level.txt0000644000000000000240000000001212565162055022067 0ustar rootstaff00000000000000otherstuf otherstuf-1.1.0/PKG-INFO0000644000000000000240000001441412565162056014731 0ustar rootstaff00000000000000Metadata-Version: 1.1 Name: otherstuf Version: 1.1.0 Summary: Attributes-accessible mappings chainstuf (like ChainMap) & counterstuf (like Counter) Home-page: https://bitbucket.org/jeunice/otherstuf Author: Jonathan Eunice Author-email: jonathan.eunice@gmail.com License: Apache License 2.0 Description: | |version| |downloads| |versions| |impls| |wheel| |coverage| .. |version| image:: http://img.shields.io/pypi/v/otherstuf.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/otherstuf .. |downloads| image:: http://img.shields.io/pypi/dm/otherstuf.svg?style=flat :alt: PyPI Package monthly downloads :target: https://pypi.python.org/pypi/otherstuf .. |versions| image:: https://img.shields.io/pypi/pyversions/otherstuf.svg :alt: Supported versions :target: https://pypi.python.org/pypi/otherstuf .. |impls| image:: https://img.shields.io/pypi/implementation/otherstuf.svg :alt: Supported implementations :target: https://pypi.python.org/pypi/otherstuf .. |wheel| image:: https://img.shields.io/pypi/wheel/otherstuf.svg :alt: Wheel packaging support :target: https://pypi.python.org/pypi/otherstuf .. |coverage| image:: https://img.shields.io/badge/test_coverage-100%25-6600CC.svg :alt: Test line coverage :target: https://pypi.python.org/pypi/otherstuf Attribute-accesible collections inspired by `stuf `_. Implements ``chainstuf`` and ``counterstuf``: versions of ``ChainMap`` and ``Counter`` that expose their keys as attributes. The ultimate goal of this module is to have these functions available in the ``stuf`` module, and this sidecar to be retired. Usage ===== Use these just like you would ``ChainMap`` and ``Counter``, except that you get attribute-style access as well. For ``chainstuf``:: from otherstuf import chainstuf d1 = dict(this=1, that=2) d2 = dict(roger=99, that=100) # test simple attribute equivalence c = chainstuf(d1, d2) assert c.this == 1 assert c.roger == 99 c.roger = 'wilco' assert c.roger print "roger", c.roger d1.update(feeling='fancypants!') print "i'm feeling", c.feeling # passed through, since d2 lacks 'feeling' Given recent versions (e.g. beyond 0.9.10) of ``stuf``, one could simply use ``from stuf import chainstuf``. This portion of the ``otherstuf`` sidecar is now superfluous. For ``counterstuf``:: from otherstuf import counterstuf c = counterstuf() c.update("this and this is this but that isn't this".split()) c.total = sum(c.values()) print "everything:", c.total print "'this' mentioned", c.this, "times" print "'bozo' mentioned", c.bozo, "times" print c Notes ===== * Version 1.1.0 initates automated test coverage metrics. Test coverage started at 88%. Cleanups got coverage to 100%. *Hooah!* * Automated multi-version testing managed with `pytest `_, `pytest-cov `_, `coverage `_ and `tox `_. Packaging linting with `pyroma `_. Successfully packaged for, and tested against, all late-model versions of Python: 2.6, 2.7, 3.2, 3.3, 3.4, and 3.5 pre-release (3.5.0b3) as well as PyPy 2.6.0 (based on 2.7.9) and PyPy3 2.4.0 (based on 3.2.5). Test line coverage 100%. * As of 1.0.0, updated to use semantic versioning and the Apache Software License. * Recent builds of ``stuf`` have left Python 2.6 out in the cold. This package requires ``stuf==0.9.14`` for 2.6--the last version to successfully install there. Newer Python releases will get ``stuf>=0.9.16``. I've submitted a patch for 2.6 installability to carry forward; we'll have to see where that goes. * The author, `Jonathan Eunice `_ or `@jeunice on Twitter `_ welcomes your comments and suggestions. Installation ============ To install or upgrade to the latest version:: pip install -U otherstuf To ``easy_install`` under a specific Python version (3.3 in this example):: python3.3 -m easy_install --upgrade otherstuf (You may need to prefix these with ``sudo`` to authorize installation. In environments without super-user privileges, you may want to use ``pip``'s ``--user`` option, to install only for a single user, rather than system-wide.) Keywords: Counter ChainMap stuf attribute mapping nested Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: Apache Software License Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries :: Python Modules otherstuf-1.1.0/README.rst0000644000076500000240000001013612565161753016004 0ustar jeunicestaff00000000000000| |version| |downloads| |versions| |impls| |wheel| |coverage| .. |version| image:: http://img.shields.io/pypi/v/otherstuf.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/otherstuf .. |downloads| image:: http://img.shields.io/pypi/dm/otherstuf.svg?style=flat :alt: PyPI Package monthly downloads :target: https://pypi.python.org/pypi/otherstuf .. |versions| image:: https://img.shields.io/pypi/pyversions/otherstuf.svg :alt: Supported versions :target: https://pypi.python.org/pypi/otherstuf .. |impls| image:: https://img.shields.io/pypi/implementation/otherstuf.svg :alt: Supported implementations :target: https://pypi.python.org/pypi/otherstuf .. |wheel| image:: https://img.shields.io/pypi/wheel/otherstuf.svg :alt: Wheel packaging support :target: https://pypi.python.org/pypi/otherstuf .. |coverage| image:: https://img.shields.io/badge/test_coverage-100%25-6600CC.svg :alt: Test line coverage :target: https://pypi.python.org/pypi/otherstuf Attribute-accesible collections inspired by `stuf `_. Implements ``chainstuf`` and ``counterstuf``: versions of ``ChainMap`` and ``Counter`` that expose their keys as attributes. The ultimate goal of this module is to have these functions available in the ``stuf`` module, and this sidecar to be retired. Usage ===== Use these just like you would ``ChainMap`` and ``Counter``, except that you get attribute-style access as well. For ``chainstuf``:: from otherstuf import chainstuf d1 = dict(this=1, that=2) d2 = dict(roger=99, that=100) # test simple attribute equivalence c = chainstuf(d1, d2) assert c.this == 1 assert c.roger == 99 c.roger = 'wilco' assert c.roger print "roger", c.roger d1.update(feeling='fancypants!') print "i'm feeling", c.feeling # passed through, since d2 lacks 'feeling' Given recent versions (e.g. beyond 0.9.10) of ``stuf``, one could simply use ``from stuf import chainstuf``. This portion of the ``otherstuf`` sidecar is now superfluous. For ``counterstuf``:: from otherstuf import counterstuf c = counterstuf() c.update("this and this is this but that isn't this".split()) c.total = sum(c.values()) print "everything:", c.total print "'this' mentioned", c.this, "times" print "'bozo' mentioned", c.bozo, "times" print c Notes ===== * Version 1.1.0 initates automated test coverage metrics. Test coverage started at 88%. Cleanups got coverage to 100%. *Hooah!* * Automated multi-version testing managed with `pytest `_, `pytest-cov `_, `coverage `_ and `tox `_. Packaging linting with `pyroma `_. Successfully packaged for, and tested against, all late-model versions of Python: 2.6, 2.7, 3.2, 3.3, 3.4, and 3.5 pre-release (3.5.0b3) as well as PyPy 2.6.0 (based on 2.7.9) and PyPy3 2.4.0 (based on 3.2.5). Test line coverage 100%. * As of 1.0.0, updated to use semantic versioning and the Apache Software License. * Recent builds of ``stuf`` have left Python 2.6 out in the cold. This package requires ``stuf==0.9.14`` for 2.6--the last version to successfully install there. Newer Python releases will get ``stuf>=0.9.16``. I've submitted a patch for 2.6 installability to carry forward; we'll have to see where that goes. * The author, `Jonathan Eunice `_ or `@jeunice on Twitter `_ welcomes your comments and suggestions. Installation ============ To install or upgrade to the latest version:: pip install -U otherstuf To ``easy_install`` under a specific Python version (3.3 in this example):: python3.3 -m easy_install --upgrade otherstuf (You may need to prefix these with ``sudo`` to authorize installation. In environments without super-user privileges, you may want to use ``pip``'s ``--user`` option, to install only for a single user, rather than system-wide.)otherstuf-1.1.0/setup.cfg0000644000000000000240000000007312565162056015451 0ustar rootstaff00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 otherstuf-1.1.0/setup.py0000644000076500000240000000352212565162051016020 0ustar jeunicestaff00000000000000#!/usr/bin/env python from setuptools import setup from codecs import open import sys _PY26 = sys.version_info[:2] == (2,6) STUF = 'stuf==0.9.14' if _PY26 else 'stuf>=0.9.16' def lines(text): """ Returns each non-blank line in text enclosed in a list. See http://pypi.python.org/pypi/textdata for more sophisticated version. """ return [l.strip() for l in text.strip().splitlines() if l.strip()] setup( name='otherstuf', version='1.1.0', author='Jonathan Eunice', author_email='jonathan.eunice@gmail.com', description='Attributes-accessible mappings chainstuf (like ChainMap) & counterstuf (like Counter)', long_description=open('README.rst', encoding='utf-8').read(), url='https://bitbucket.org/jeunice/otherstuf', license='Apache License 2.0', packages=['otherstuf'], setup_requires=[], install_requires=[STUF], tests_require=['tox', 'pytest', 'pytest-cov', 'coverage'], test_suite="test", zip_safe=False, keywords='Counter ChainMap stuf attribute mapping nested', classifiers=lines(""" Development Status :: 4 - Beta Operating System :: OS Independent License :: OSI Approved :: Apache Software License Intended Audience :: Developers Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.2 Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Libraries :: Python Modules """) ) otherstuf-1.1.0/test/0000755000000000000240000000000012565162056014607 5ustar rootstaff00000000000000otherstuf-1.1.0/test/test.py0000644000076500000240000000544112565161367016631 0ustar jeunicestaff00000000000000 from otherstuf import * import sys from stuf import stuf import pytest def test_chainstuf(): """Test chainstuf class""" # make some base dicts d1 = dict(this=1, that=2) d2 = dict(roger=99, that=100) # test simple attribute equivalence dd = chainstuf(d1, d2) assert dd.this == 1 assert dd.roger == 99 assert dd.this == dd['this'] assert dd.that == dd['that'] assert dd.roger == dd['roger'] # set value on chainstuf, ensure properly set, in top dict dd.roger = 'wilco' assert dd.roger == 'wilco' assert dd.roger == d1['roger'] # test new_child dd2 = dd.new_child() dd2.smorg = 44 assert dd2.smorg == 44 dd.roger = 'roger' assert dd2.roger == 'roger' with pytest.raises(KeyError): dd.nork def test_files(): # stuf (<0.9.9) had a problem with files being assigned in a stuf() # constructor. It was fixed in 0.9.10, though not for PyPy. This test # demonstrates that otherstuf.chainstuf does not manifest this bug. To be # fair, the bug was in stuf's base collections (stuf and orderedstuf), not # stuf.chainstuf. So this test is included out of an abundance of caution. # Get names of files that won't be munged by py.test's capturing mechanism # (sys.stdout and sys.stderr definitely will be overtaken by py.test, but # their primitive double-underscore names won't be). This doesn't seem to # be an issue with Python 2.x, but spuriously screws up the test otherwise # in Python 3.x (gives false negative, saying module not working when it is) f1 = sys.__stdout__ f2 = sys.__stderr__ f3 = sys.__stdin__ d1 = dict(a=44, b=f2, c=[f2, f3]) d2 = dict(a=f1) o = chainstuf(d2, d1) assert o.a is f1 assert o.b is f2 assert len(o.c) == 2 assert o.c[0] is f2 assert o.c[1] is f3 # first push oo = o.new_child() oo.b = f1 oo.c = 12 assert oo.a is f1 assert oo.b is f1 assert oo.c == 12 # now try it with an update d3 = dict(b=f1, c=12) oo2 = oo.new_child() oo2.update(d3) assert oo2.a is f1 assert oo2.b is f1 assert oo2.c == 12 # second push ooo = oo.new_child() ooo.update(dict(a=f2, b=f3)) assert ooo.a is f2 assert ooo.b is f3 assert ooo.c == 12 def test_counterstuf(): """Test counterstuf class""" c = counterstuf() c.update("this and this is this but that isn't this".split()) c.total = sum(c.values()) assert c.total == 9 assert c.this == 4 assert c.but == 1 assert c.bozo == 0 c2 = counterstuf().update_self("big big small big medium xlarge".split()) assert c2.medium == 1 assert dict(c2.most_common()) == dict([('big', 3), ('small', 1), ('medium', 1), ('xlarge', 1)]) c3 = c.copy() assert c3 == c assert c3 is not c