Skip to content

Commit

Permalink
Updates packaging for pypi.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsc committed Jan 26, 2010
1 parent e4f1550 commit 1ae562c
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 14 deletions.
Empty file removed README.md
Empty file.
62 changes: 62 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
bunch
=====

Bunch is a dictionary that supports attribute-style access, a la JavaScript.

>>> b = Bunch()
>>> b.hello = 'world'
>>> b.hello
'world'
>>> b['hello'] += "!"
>>> b.hello
'world!'
>>> b.foo = Bunch(lol=True)
>>> b.foo.lol
True
>>> b.foo is b['foo']
True


Dictionary Methods
------------------

A Bunch is a subclass of ``dict``; it supports all the methods a ``dict`` does:

>>> b.keys()
['foo', 'hello']

Including ``update()``:

>>> b.update({ 'ponies': 'are pretty!' }, hello=42)
>>> print repr(b)
Bunch(foo=Bunch(lol=True), hello=42, ponies='are pretty!')

As well as iteration:

>>> [ (k,b[k]) for k in b ]
[('ponies', 'are pretty!'), ('foo', Bunch(lol=True)), ('hello', 42)]

And "splats":

>>> "The {knights} who say {ni}!".format(**Bunch(knights='lolcats', ni='can haz'))
'The lolcats who say can haz!'


Conversion
----------

Bunch converts easily to (``unbunchify/Bunch.toDict``) and from (``bunchify/Bunch.fromDict``) a normal ``dict``, making it easy to cleanly serialize them to JSON or YAML.


Import Safe
-----------

It is safe to ``import *`` from this module. You'll get:

__all__ = ('Bunch', 'bunchify','unbunchify')


Feedback
--------

Open a ticket on [github](http://github.com/dsc/bunch), or send me an email at [[email protected]](mailto:[email protected]).
15 changes: 10 additions & 5 deletions bunch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
""" bunch provides Bunch, a subclass of dictionary with attribute-style access,
and un/bunchify(), two utility functions for dictionary conversion. Bunches
can also be converted Bunch.to/fromDict().
""" Bunch is a subclass of dict with attribute-style access.
>>> b = Bunch()
>>> b.hello = 'world'
Expand All @@ -14,9 +12,16 @@
True
>>> b.foo is b['foo']
True
It is safe to import * from this module:
__all__ = ('Bunch', 'bunchify','unbunchify')
un/bunchify provide dictionary conversion; Bunches can also be
converted via Bunch.to/fromDict().
"""

__all__ = ('Bunch', 'bunchify',)
__all__ = ('Bunch', 'bunchify','unbunchify')


class Bunch(dict):
Expand Down Expand Up @@ -56,7 +61,7 @@ class Bunch(dict):
>>> "The {knights} who say {ni}!".format(**Bunch(knights='lolcats', ni='can haz'))
'The lolcats who say can haz!'
See Bunch.toDict, Bunch.fromDict, and bunchify for notes about conversion.
See unbunchify/Bunch.toDict, bunchify/Bunch.fromDict for notes about conversion.
"""

def __contains__(self, k):
Expand Down
35 changes: 26 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
#! python
from setuptools import setup, find_packages
import os
from distutils.core import setup

version = "1.0.0"

# Read the long description from the README.txt
here = os.path.abspath(os.path.dirname(__file__))
f = open(os.path.join(here, 'README.rst'))
readme = f.read()
f.close()


setup(
name = "bunch",
description = "A dot-accessible dictionary (a la JavaScript objects)",
version = "1.0.0",
license = 'MIT',
version = version,
author = "David Schoonover",
author_email = "[email protected]",
long_description = """
A dot-accessible dictionary (a la JavaScript objects).
""",
long_description = readme,
url = "http://tire.less.ly/hacking/bunch",
platform = 'Any',
download_url = "http://pypi.python.org/packages/source/B/bunch/bunch-%s.tar.gz" % version,

packages=['bunch',],
zip_safe = True,
keywords = ['dict', 'bunch', 'mapping', 'utilities',],
classifiers = [
'Programming Language :: Python',
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Intended Audience :: Developers',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities',
]
license = 'MIT',
zip_safe = True,
)

0 comments on commit 1ae562c

Please sign in to comment.