[Python-modules-commits] [python-munch] 01/03: Importing munch-2.0.4.tar.gz

Clint Byrum spamaps at moszumanska.debian.org
Tue Nov 10 18:35:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

spamaps pushed a commit to branch master
in repository python-munch.

commit b9dc6eaf67b821f2b6af98c659649c6987fb0e1f
Author: Clint Byrum <clint at fewbar.com>
Date:   Tue Nov 10 10:13:22 2015 -0800

    Importing munch-2.0.4.tar.gz
---
 LICENSE.txt                         |  19 ++
 MANIFEST.in                         |   2 +
 PKG-INFO                            |  25 +++
 README.md                           | 102 +++++++++
 munch.egg-info/PKG-INFO             |  25 +++
 munch.egg-info/SOURCES.txt          |  10 +
 munch.egg-info/dependency_links.txt |   1 +
 munch.egg-info/top_level.txt        |   1 +
 munch/__init__.py                   | 411 ++++++++++++++++++++++++++++++++++++
 munch/python3_compat.py             |  22 ++
 setup.cfg                           |   5 +
 setup.py                            |  47 +++++
 12 files changed, 670 insertions(+)

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..e764668
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,19 @@
+Copyright (c) 2010 David Schoonover
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..6006776
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include LICENSE.txt
+include README.md
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..fb24c3c
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,25 @@
+Metadata-Version: 1.1
+Name: munch
+Version: 2.0.4
+Summary: A dot-accessible dictionary (a la JavaScript objects).
+Home-page: http://github.com/Infinidat/munch
+Author: Rotem Yaari
+Author-email: vmalloc at gmail.com
+License: MIT
+Description: UNKNOWN
+Keywords: munch,dict,mapping,container,collection
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Software Development
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Utilities
+Classifier: License :: OSI Approved :: MIT License
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..27ee9b3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,102 @@
+[![Build Status](https://travis-ci.org/Infinidat/munch.svg?branch=master)](https://travis-ci.org/Infinidat/munch)
+[![Latest Version](https://img.shields.io/pypi/v/munch.svg)](https://pypi.python.org/pypi/munch/)
+[![Supported Python versions](https://img.shields.io/pypi/pyversions/munch.svg)](https://pypi.python.org/pypi/munch/)
+[![Downloads](https://img.shields.io/pypi/dm/munch.svg)](https://pypi.python.org/pypi/munch/)
+
+munch
+==========
+
+munch is a fork of David Schoonover's **Bunch** package, providing similar functionality. 99% of the work was done by him, and the fork was made mainly for lack of responsiveness for fixes and maintenance on the original code.
+
+Munch is a dictionary that supports attribute-style access, a la JavaScript.
+
+````py
+>>> b = Munch()
+>>> b.hello = 'world'
+>>> b.hello
+'world'
+>>> b['hello'] += "!"
+>>> b.hello
+'world!'
+>>> b.foo = Munch(lol=True)
+>>> b.foo.lol
+True
+>>> b.foo is b['foo']
+True
+````
+
+
+Dictionary Methods
+------------------
+
+A Munch is a subclass of ``dict``; it supports all the methods a ``dict`` does:
+
+````py
+>>> b.keys()
+['foo', 'hello']
+````
+
+Including ``update()``:
+
+````py
+>>> b.update({ 'ponies': 'are pretty!' }, hello=42)
+>>> print repr(b)
+Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
+````
+
+As well as iteration:
+
+````py
+>>> [ (k,b[k]) for k in b ]
+[('ponies', 'are pretty!'), ('foo', Munch(lol=True)), ('hello', 42)]
+````
+
+And "splats":
+
+````py
+>>> "The {knights} who say {ni}!".format(**Munch(knights='lolcats', ni='can haz'))
+'The lolcats who say can haz!'
+````
+
+
+Serialization
+-------------
+
+Munches happily and transparently serialize to JSON and YAML.
+
+````py
+>>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
+>>> import json
+>>> json.dumps(b)
+'{"ponies": "are pretty!", "foo": {"lol": true}, "hello": 42}'
+````
+
+If JSON support is present (``json`` or ``simplejson``), ``Munch`` will have a ``toJSON()`` method which returns the object as a JSON string.
+
+If you have [PyYAML](http://pyyaml.org/wiki/PyYAML) installed, Munch attempts to register itself with the various YAML Representers so that Munches can be transparently dumped and loaded.
+
+````py
+>>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
+>>> import yaml
+>>> yaml.dump(b)
+'!munch.Munch\nfoo: !munch.Munch {lol: true}\nhello: 42\nponies: are pretty!\n'
+>>> yaml.safe_dump(b)
+'foo: {lol: true}\nhello: 42\nponies: are pretty!\n'
+````
+
+In addition, Munch instances will have a ``toYAML()`` method that returns the YAML string using ``yaml.safe_dump()``. This method also replaces ``__str__`` if present, as I find it far more readable. You can revert back to Python's default use of ``__repr__`` with a simple assignment: ``Munch.__str__ = Munch.__repr__``. The Munch class will also have a static method ``Munch.fromYAML()``, which loads a Munch out of a YAML string.
+
+Finally, Munch converts easily and recursively to (``unmunchify()``, ``Munch.toDict()``) and from (``munchify()``, ``Munch.fromDict()``) a normal ``dict``, making it easy to cleanly serialize them in other formats.
+
+
+Miscellaneous
+-------------
+
+* It is safe to ``import *`` from this module. You'll get: ``Munch``, ``munchify``, and ``unmunchify``.
+* Ample Tests. Just run ``make test`` from the project root.
+
+Feedback
+--------
+
+Open a ticket / fork the project on [GitHub](http://github.com/Infinidat/munch).
+
diff --git a/munch.egg-info/PKG-INFO b/munch.egg-info/PKG-INFO
new file mode 100644
index 0000000..fb24c3c
--- /dev/null
+++ b/munch.egg-info/PKG-INFO
@@ -0,0 +1,25 @@
+Metadata-Version: 1.1
+Name: munch
+Version: 2.0.4
+Summary: A dot-accessible dictionary (a la JavaScript objects).
+Home-page: http://github.com/Infinidat/munch
+Author: Rotem Yaari
+Author-email: vmalloc at gmail.com
+License: MIT
+Description: UNKNOWN
+Keywords: munch,dict,mapping,container,collection
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Software Development
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Utilities
+Classifier: License :: OSI Approved :: MIT License
diff --git a/munch.egg-info/SOURCES.txt b/munch.egg-info/SOURCES.txt
new file mode 100644
index 0000000..f6687f4
--- /dev/null
+++ b/munch.egg-info/SOURCES.txt
@@ -0,0 +1,10 @@
+LICENSE.txt
+MANIFEST.in
+README.md
+setup.py
+munch/__init__.py
+munch/python3_compat.py
+munch.egg-info/PKG-INFO
+munch.egg-info/SOURCES.txt
+munch.egg-info/dependency_links.txt
+munch.egg-info/top_level.txt
\ No newline at end of file
diff --git a/munch.egg-info/dependency_links.txt b/munch.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/munch.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/munch.egg-info/top_level.txt b/munch.egg-info/top_level.txt
new file mode 100644
index 0000000..3d7d7ec
--- /dev/null
+++ b/munch.egg-info/top_level.txt
@@ -0,0 +1 @@
+munch
diff --git a/munch/__init__.py b/munch/__init__.py
new file mode 100644
index 0000000..49d6525
--- /dev/null
+++ b/munch/__init__.py
@@ -0,0 +1,411 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+""" Munch is a subclass of dict with attribute-style access.
+
+    >>> b = Munch()
+    >>> b.hello = 'world'
+    >>> b.hello
+    'world'
+    >>> b['hello'] += "!"
+    >>> b.hello
+    'world!'
+    >>> b.foo = Munch(lol=True)
+    >>> b.foo.lol
+    True
+    >>> b.foo is b['foo']
+    True
+
+    It is safe to import * from this module:
+
+        __all__ = ('Munch', 'munchify','unmunchify')
+
+    un/munchify provide dictionary conversion; Munches can also be
+    converted via Munch.to/fromDict().
+"""
+
+__version__ = '2.0.4'
+VERSION = tuple(map(int, __version__.split('.')))
+
+__all__ = ('Munch', 'munchify','unmunchify',)
+
+from .python3_compat import *
+
+class Munch(dict):
+    """ A dictionary that provides attribute-style access.
+
+        >>> b = Munch()
+        >>> b.hello = 'world'
+        >>> b.hello
+        'world'
+        >>> b['hello'] += "!"
+        >>> b.hello
+        'world!'
+        >>> b.foo = Munch(lol=True)
+        >>> b.foo.lol
+        True
+        >>> b.foo is b['foo']
+        True
+
+        A Munch is a subclass of dict; it supports all the methods a dict does...
+
+        >>> sorted(b.keys())
+        ['foo', 'hello']
+
+        Including update()...
+
+        >>> b.update({ 'ponies': 'are pretty!' }, hello=42)
+        >>> print (repr(b))
+        Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
+
+        As well as iteration...
+
+        >>> sorted([ (k,b[k]) for k in b ])
+        [('foo', Munch({'lol': True})), ('hello', 42), ('ponies', 'are pretty!')]
+
+        And "splats".
+
+        >>> "The {knights} who say {ni}!".format(**Munch(knights='lolcats', ni='can haz'))
+        'The lolcats who say can haz!'
+
+        See unmunchify/Munch.toDict, munchify/Munch.fromDict for notes about conversion.
+    """
+
+    def __contains__(self, k):
+        """ >>> b = Munch(ponies='are pretty!')
+            >>> 'ponies' in b
+            True
+            >>> 'foo' in b
+            False
+            >>> b['foo'] = 42
+            >>> 'foo' in b
+            True
+            >>> b.hello = 'hai'
+            >>> 'hello' in b
+            True
+            >>> b[None] = 123
+            >>> None in b
+            True
+            >>> b[False] = 456
+            >>> False in b
+            True
+        """
+        try:
+            return dict.__contains__(self, k) or hasattr(self, k)
+        except:
+            return False
+
+    # only called if k not found in normal places
+    def __getattr__(self, k):
+        """ Gets key if it exists, otherwise throws AttributeError.
+
+            nb. __getattr__ is only called if key is not found in normal places.
+
+            >>> b = Munch(bar='baz', lol={})
+            >>> b.foo
+            Traceback (most recent call last):
+                ...
+            AttributeError: foo
+
+            >>> b.bar
+            'baz'
+            >>> getattr(b, 'bar')
+            'baz'
+            >>> b['bar']
+            'baz'
+
+            >>> b.lol is b['lol']
+            True
+            >>> b.lol is getattr(b, 'lol')
+            True
+        """
+        try:
+            # Throws exception if not in prototype chain
+            return object.__getattribute__(self, k)
+        except AttributeError:
+            try:
+                return self[k]
+            except KeyError:
+                raise AttributeError(k)
+
+    def __setattr__(self, k, v):
+        """ Sets attribute k if it exists, otherwise sets key k. A KeyError
+            raised by set-item (only likely if you subclass Munch) will
+            propagate as an AttributeError instead.
+
+            >>> b = Munch(foo='bar', this_is='useful when subclassing')
+            >>> hasattr(b.values, '__call__')
+            True
+            >>> b.values = 'uh oh'
+            >>> b.values
+            'uh oh'
+            >>> b['values']
+            Traceback (most recent call last):
+                ...
+            KeyError: 'values'
+        """
+        try:
+            # Throws exception if not in prototype chain
+            object.__getattribute__(self, k)
+        except AttributeError:
+            try:
+                self[k] = v
+            except:
+                raise AttributeError(k)
+        else:
+            object.__setattr__(self, k, v)
+
+    def __delattr__(self, k):
+        """ Deletes attribute k if it exists, otherwise deletes key k. A KeyError
+            raised by deleting the key--such as when the key is missing--will
+            propagate as an AttributeError instead.
+
+            >>> b = Munch(lol=42)
+            >>> del b.lol
+            >>> b.lol
+            Traceback (most recent call last):
+                ...
+            AttributeError: lol
+        """
+        try:
+            # Throws exception if not in prototype chain
+            object.__getattribute__(self, k)
+        except AttributeError:
+            try:
+                del self[k]
+            except KeyError:
+                raise AttributeError(k)
+        else:
+            object.__delattr__(self, k)
+
+    def toDict(self):
+        """ Recursively converts a munch back into a dictionary.
+
+            >>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
+            >>> sorted(b.toDict().items())
+            [('foo', {'lol': True}), ('hello', 42), ('ponies', 'are pretty!')]
+
+            See unmunchify for more info.
+        """
+        return unmunchify(self)
+
+    def __repr__(self):
+        """ Invertible* string-form of a Munch.
+
+            >>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
+            >>> print (repr(b))
+            Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
+            >>> eval(repr(b))
+            Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
+
+            >>> with_spaces = Munch({1: 2, 'a b': 9, 'c': Munch({'simple': 5})})
+            >>> print (repr(with_spaces))
+            Munch({'a b': 9, 1: 2, 'c': Munch({'simple': 5})})
+            >>> eval(repr(with_spaces))
+            Munch({'a b': 9, 1: 2, 'c': Munch({'simple': 5})})
+
+            (*) Invertible so long as collection contents are each repr-invertible.
+        """
+        return '%s(%s)' % (self.__class__.__name__, dict.__repr__(self))
+
+
+
+    def __dir__(self):
+        return list(iterkeys(self))
+
+    __members__ = __dir__ # for python2.x compatibility
+
+    @staticmethod
+    def fromDict(d):
+        """ Recursively transforms a dictionary into a Munch via copy.
+
+            >>> b = Munch.fromDict({'urmom': {'sez': {'what': 'what'}}})
+            >>> b.urmom.sez.what
+            'what'
+
+            See munchify for more info.
+        """
+        return munchify(d)
+
+
+
+# While we could convert abstract types like Mapping or Iterable, I think
+# munchify is more likely to "do what you mean" if it is conservative about
+# casting (ex: isinstance(str,Iterable) == True ).
+#
+# Should you disagree, it is not difficult to duplicate this function with
+# more aggressive coercion to suit your own purposes.
+
+def munchify(x):
+    """ Recursively transforms a dictionary into a Munch via copy.
+
+        >>> b = munchify({'urmom': {'sez': {'what': 'what'}}})
+        >>> b.urmom.sez.what
+        'what'
+
+        munchify can handle intermediary dicts, lists and tuples (as well as
+        their subclasses), but ymmv on custom datatypes.
+
+        >>> b = munchify({ 'lol': ('cats', {'hah':'i win again'}),
+        ...         'hello': [{'french':'salut', 'german':'hallo'}] })
+        >>> b.hello[0].french
+        'salut'
+        >>> b.lol[1].hah
+        'i win again'
+
+        nb. As dicts are not hashable, they cannot be nested in sets/frozensets.
+    """
+    if isinstance(x, dict):
+        return Munch( (k, munchify(v)) for k,v in iteritems(x) )
+    elif isinstance(x, (list, tuple)):
+        return type(x)( munchify(v) for v in x )
+    else:
+        return x
+
+def unmunchify(x):
+    """ Recursively converts a Munch into a dictionary.
+
+        >>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
+        >>> sorted(unmunchify(b).items())
+        [('foo', {'lol': True}), ('hello', 42), ('ponies', 'are pretty!')]
+
+        unmunchify will handle intermediary dicts, lists and tuples (as well as
+        their subclasses), but ymmv on custom datatypes.
+
+        >>> b = Munch(foo=['bar', Munch(lol=True)], hello=42,
+        ...         ponies=('are pretty!', Munch(lies='are trouble!')))
+        >>> sorted(unmunchify(b).items()) #doctest: +NORMALIZE_WHITESPACE
+        [('foo', ['bar', {'lol': True}]), ('hello', 42), ('ponies', ('are pretty!', {'lies': 'are trouble!'}))]
+
+        nb. As dicts are not hashable, they cannot be nested in sets/frozensets.
+    """
+    if isinstance(x, dict):
+        return dict( (k, unmunchify(v)) for k,v in iteritems(x) )
+    elif isinstance(x, (list, tuple)):
+        return type(x)( unmunchify(v) for v in x )
+    else:
+        return x
+
+
+### Serialization
+
+try:
+    try:
+        import json
+    except ImportError:
+        import simplejson as json
+
+    def toJSON(self, **options):
+        """ Serializes this Munch to JSON. Accepts the same keyword options as `json.dumps()`.
+
+            >>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
+            >>> json.dumps(b) == b.toJSON()
+            True
+        """
+        return json.dumps(self, **options)
+
+    Munch.toJSON = toJSON
+
+except ImportError:
+    pass
+
+
+
+
+try:
+    # Attempt to register ourself with PyYAML as a representer
+    import yaml
+    from yaml.representer import Representer, SafeRepresenter
+
+    def from_yaml(loader, node):
+        """ PyYAML support for Munches using the tag `!munch` and `!munch.Munch`.
+
+            >>> import yaml
+            >>> yaml.load('''
+            ... Flow style: !munch.Munch { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
+            ... Block style: !munch
+            ...   Clark : Evans
+            ...   Brian : Ingerson
+            ...   Oren  : Ben-Kiki
+            ... ''') #doctest: +NORMALIZE_WHITESPACE
+            {'Flow style': Munch(Brian='Ingerson', Clark='Evans', Oren='Ben-Kiki'),
+             'Block style': Munch(Brian='Ingerson', Clark='Evans', Oren='Ben-Kiki')}
+
+            This module registers itself automatically to cover both Munch and any
+            subclasses. Should you want to customize the representation of a subclass,
+            simply register it with PyYAML yourself.
+        """
+        data = Munch()
+        yield data
+        value = loader.construct_mapping(node)
+        data.update(value)
+
+
+    def to_yaml_safe(dumper, data):
+        """ Converts Munch to a normal mapping node, making it appear as a
+            dict in the YAML output.
+
+            >>> b = Munch(foo=['bar', Munch(lol=True)], hello=42)
+            >>> import yaml
+            >>> yaml.safe_dump(b, default_flow_style=True)
+            '{foo: [bar, {lol: true}], hello: 42}\\n'
+        """
+        return dumper.represent_dict(data)
+
+    def to_yaml(dumper, data):
+        """ Converts Munch to a representation node.
+
+            >>> b = Munch(foo=['bar', Munch(lol=True)], hello=42)
+            >>> import yaml
+            >>> yaml.dump(b, default_flow_style=True)
+            '!munch.Munch {foo: [bar, !munch.Munch {lol: true}], hello: 42}\\n'
+        """
+        return dumper.represent_mapping(u('!munch.Munch'), data)
+
+
+    yaml.add_constructor(u('!munch'), from_yaml)
+    yaml.add_constructor(u('!munch.Munch'), from_yaml)
+
+    SafeRepresenter.add_representer(Munch, to_yaml_safe)
+    SafeRepresenter.add_multi_representer(Munch, to_yaml_safe)
+
+    Representer.add_representer(Munch, to_yaml)
+    Representer.add_multi_representer(Munch, to_yaml)
+
+
+    # Instance methods for YAML conversion
+    def toYAML(self, **options):
+        """ Serializes this Munch to YAML, using `yaml.safe_dump()` if
+            no `Dumper` is provided. See the PyYAML documentation for more info.
+
+            >>> b = Munch(foo=['bar', Munch(lol=True)], hello=42)
+            >>> import yaml
+            >>> yaml.safe_dump(b, default_flow_style=True)
+            '{foo: [bar, {lol: true}], hello: 42}\\n'
+            >>> b.toYAML(default_flow_style=True)
+            '{foo: [bar, {lol: true}], hello: 42}\\n'
+            >>> yaml.dump(b, default_flow_style=True)
+            '!munch.Munch {foo: [bar, !munch.Munch {lol: true}], hello: 42}\\n'
+            >>> b.toYAML(Dumper=yaml.Dumper, default_flow_style=True)
+            '!munch.Munch {foo: [bar, !munch.Munch {lol: true}], hello: 42}\\n'
+        """
+        opts = dict(indent=4, default_flow_style=False)
+        opts.update(options)
+        if 'Dumper' not in opts:
+            return yaml.safe_dump(self, **opts)
+        else:
+            return yaml.dump(self, **opts)
+
+    def fromYAML(*args, **kwargs):
+        return munchify( yaml.load(*args, **kwargs) )
+
+    Munch.toYAML = toYAML
+    Munch.fromYAML = staticmethod(fromYAML)
+
+except ImportError:
+    pass
+
+
+if __name__ == "__main__":
+    import doctest
+    doctest.testmod()
+
diff --git a/munch/python3_compat.py b/munch/python3_compat.py
new file mode 100644
index 0000000..c6fa289
--- /dev/null
+++ b/munch/python3_compat.py
@@ -0,0 +1,22 @@
+import sys
+
+_PY2 = (sys.version_info < (3,0))
+
+identity = lambda x : x
+
+# u('string') replaces the forwards-incompatible u'string'
+if _PY2:
+    import codecs
+    def u(string):
+        return codecs.unicode_escape_decode(string)[0]
+else:
+    u = identity
+
+# dict.iteritems(), dict.iterkeys() is also incompatible
+if _PY2:
+    iteritems = dict.iteritems
+    iterkeys = dict.iterkeys
+else:
+    iteritems = dict.items
+    iterkeys  = dict.keys
+
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..80b67b8
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,47 @@
+#!python
+# -*- coding: utf-8 -*-
+import sys, os, re
+from os.path import dirname, abspath, join
+from setuptools import setup, find_packages
+
+
+HERE = abspath(dirname(__file__))
+readme = open(join(HERE, 'README.md')).read()
+
+package_file = open(join(HERE, 'munch', '__init__.py'), 'rU')
+__version__ = re.sub(
+    r".*\b__version__\s+=\s+'([^']+)'.*",
+    r'\1',
+    [ line.strip() for line in package_file if '__version__' in line ].pop(0)
+)
+
+
+setup(
+    name             = "munch",
+    version          = __version__,
+    description      = "A dot-accessible dictionary (a la JavaScript objects).",
+    url              = "http://github.com/Infinidat/munch",
+
+    author           = "Rotem Yaari",
+    author_email     = "vmalloc at gmail.com",
+
+    packages         = find_packages(exclude=["tests"]),
+    keywords         = ['munch', 'dict', 'mapping', 'container', 'collection'],
+    classifiers      = [
+        'Development Status :: 5 - Production/Stable',
+        'Intended Audience :: Developers',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        "Programming Language :: Python :: 2.5",
+        "Programming Language :: Python :: 2.6",
+        "Programming Language :: Python :: 2.7",
+        "Programming Language :: Python :: 3.3",
+        "Programming Language :: Python :: 3.4",
+        "Programming Language :: Python :: 3.5",
+        'Topic :: Software Development',
+        'Topic :: Software Development :: Libraries',
+        'Topic :: Utilities',
+        'License :: OSI Approved :: MIT License',
+    ],
+    license          = 'MIT',
+)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-munch.git



More information about the Python-modules-commits mailing list