././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1698102092.407892 easydict-1.11/0000755000076700000240000000000014515575514012636 5ustar00mathieustaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698101651.0 easydict-1.11/CHANGES0000644000076700000240000000217514515574623013636 0ustar00mathieustaff========= CHANGELOG ========= 1.11 (2023-10-24) ================= - Fix #39: RecursionError when dict in class member (#41) - Minor changes in README 1.10 (2022-09-28) ================= * Make tests compatible with python2 and python3 (thanks @JackLangerman) * Dictify input * Fix license metadata 1.9 (2018-10-18) ================ * Fix issue #3 that update and pop now work correctly on EasyDicts. 1.8 (2018-08-17) ================ * Update package classifiers. 1.7 (2017-04-27) ================ * Prevent copying sub-EasyDicts on assignment to fix unpickling (#7, thanks @Chronos-Sk) 1.6 (2015-01-27) ================ * Allow setting attributes via setting items (thanks phivos) 1.5 (2014-08-07) ================ * Allow subclassing using self instead of class name (thanks Steve Engledow) 1.4 (2011-03-13) ================ * Access class attributes like instance attributes 1.3 (2012-02-08) ================ * Better documentation and tests 1.2 (2011-06-08) ================ * Fix inclusion of README 1.1 (2012-04-21) ================ * Switch to distutils2 1.0 (2011-04-18) ================ * Initial working version ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1664363814.0 easydict-1.11/LICENSE0000644000076700000240000001674314315026446013647 0ustar00mathieustaff GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1664363814.0 easydict-1.11/MANIFEST.in0000644000076700000240000000004314315026446014362 0ustar00mathieustaffinclude README.rst CHANGES LICENSE ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1698102092.4077547 easydict-1.11/PKG-INFO0000644000076700000240000000762414515575514013744 0ustar00mathieustaffMetadata-Version: 2.1 Name: easydict Version: 1.11 Summary: Access dict values as attributes (works recursively). Home-page: https://github.com/makinacorpus/easydict Download-URL: http://pypi.python.org/pypi/easydict/ Author: Mathieu Leplatre Author-email: mathieu.leplatre@makina-corpus.com License: LGPL-3.0 Keywords: Tools Classifier: Topic :: Utilities Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Intended Audience :: Developers Classifier: Development Status :: 5 - Production/Stable Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3) Classifier: Programming Language :: Python :: 2.5 Classifier: Programming Language :: Python :: 3.6 License-File: LICENSE .. image:: https://img.shields.io/pypi/v/easydict.svg :target: https://pypi.python.org/pypi/easydict .. image:: https://img.shields.io/pypi/dm/easydict.svg :target: https://pypi.python.org/pypi/easydict ======== Easydict ======== *EasyDict* allows to access dict values as attributes (works recursively). A Javascript-like properties dot notation for python dicts. INSTALL ======= :: pip install easydict USAGE ===== :: >>> from easydict import EasyDict as edict >>> d = edict({'foo':3, 'bar':{'x':1, 'y':2}}) >>> d.foo 3 >>> d.bar.x 1 >>> d = edict(foo=3) >>> d.foo 3 Very useful when exploiting parsed JSON content ! :: >>> from easydict import EasyDict as edict >>> from simplejson import loads >>> j = """{ "Buffer": 12, "List1": [ {"type" : "point", "coordinates" : [100.1,54.9] }, {"type" : "point", "coordinates" : [109.4,65.1] }, {"type" : "point", "coordinates" : [115.2,80.2] }, {"type" : "point", "coordinates" : [150.9,97.8] } ] }""" >>> d = edict(loads(j)) >>> d.Buffer 12 >>> d.List1[0].coordinates[1] 54.9 Can set attributes as easily as getting them : :: >>> d = EasyDict() >>> d.foo = 3 >>> d.foo 3 It is still a ``dict`` ! :: >>> d = EasyDict(log=False) >>> d.debug = True >>> d.items() [('debug', True), ('log', False)] Instance and class attributes are accessed like usual objects... :: >>> class Flower(EasyDict): ... power = 1 ... >>> f = Flower({'height': 12}) >>> f.power 1 >>> f['power'] 1 LICENSE ======= * Lesser GNU Public License AUTHORS ======= * Mathieu Leplatre |makinacom|_ .. |makinacom| image:: http://depot.makina-corpus.org/public/logo.gif .. _makinacom: http://www.makina-corpus.com Similar tools ============= * `TreeDict `_, a fast and full-featured dict-like tree container. * `addict `_ ========= CHANGELOG ========= 1.11 (2023-10-24) ================= - Fix #39: RecursionError when dict in class member (#41) - Minor changes in README 1.10 (2022-09-28) ================= * Make tests compatible with python2 and python3 (thanks @JackLangerman) * Dictify input * Fix license metadata 1.9 (2018-10-18) ================ * Fix issue #3 that update and pop now work correctly on EasyDicts. 1.8 (2018-08-17) ================ * Update package classifiers. 1.7 (2017-04-27) ================ * Prevent copying sub-EasyDicts on assignment to fix unpickling (#7, thanks @Chronos-Sk) 1.6 (2015-01-27) ================ * Allow setting attributes via setting items (thanks phivos) 1.5 (2014-08-07) ================ * Allow subclassing using self instead of class name (thanks Steve Engledow) 1.4 (2011-03-13) ================ * Access class attributes like instance attributes 1.3 (2012-02-08) ================ * Better documentation and tests 1.2 (2011-06-08) ================ * Fix inclusion of README 1.1 (2012-04-21) ================ * Switch to distutils2 1.0 (2011-04-18) ================ * Initial working version ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698102069.0 easydict-1.11/README.rst0000644000076700000240000000404514515575465014335 0ustar00mathieustaff.. image:: https://img.shields.io/pypi/v/easydict.svg :target: https://pypi.python.org/pypi/easydict .. image:: https://img.shields.io/pypi/dm/easydict.svg :target: https://pypi.python.org/pypi/easydict ======== Easydict ======== *EasyDict* allows to access dict values as attributes (works recursively). A Javascript-like properties dot notation for python dicts. INSTALL ======= :: pip install easydict USAGE ===== :: >>> from easydict import EasyDict as edict >>> d = edict({'foo':3, 'bar':{'x':1, 'y':2}}) >>> d.foo 3 >>> d.bar.x 1 >>> d = edict(foo=3) >>> d.foo 3 Very useful when exploiting parsed JSON content ! :: >>> from easydict import EasyDict as edict >>> from simplejson import loads >>> j = """{ "Buffer": 12, "List1": [ {"type" : "point", "coordinates" : [100.1,54.9] }, {"type" : "point", "coordinates" : [109.4,65.1] }, {"type" : "point", "coordinates" : [115.2,80.2] }, {"type" : "point", "coordinates" : [150.9,97.8] } ] }""" >>> d = edict(loads(j)) >>> d.Buffer 12 >>> d.List1[0].coordinates[1] 54.9 Can set attributes as easily as getting them : :: >>> d = EasyDict() >>> d.foo = 3 >>> d.foo 3 It is still a ``dict`` ! :: >>> d = EasyDict(log=False) >>> d.debug = True >>> d.items() [('debug', True), ('log', False)] Instance and class attributes are accessed like usual objects... :: >>> class Flower(EasyDict): ... power = 1 ... >>> f = Flower({'height': 12}) >>> f.power 1 >>> f['power'] 1 LICENSE ======= * Lesser GNU Public License AUTHORS ======= * Mathieu Leplatre |makinacom|_ .. |makinacom| image:: http://depot.makina-corpus.org/public/logo.gif .. _makinacom: http://www.makina-corpus.com Similar tools ============= * `TreeDict `_, a fast and full-featured dict-like tree container. * `addict `_ ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1698102092.4069698 easydict-1.11/easydict/0000755000076700000240000000000014515575514014443 5ustar00mathieustaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698101560.0 easydict-1.11/easydict/__init__.py0000644000076700000240000000654214515574470016563 0ustar00mathieustaffclass EasyDict(dict): """ Get attributes >>> d = EasyDict({'foo':3}) >>> d['foo'] 3 >>> d.foo 3 >>> d.bar Traceback (most recent call last): ... AttributeError: 'EasyDict' object has no attribute 'bar' Works recursively >>> d = EasyDict({'foo':3, 'bar':{'x':1, 'y':2}}) >>> isinstance(d.bar, dict) True >>> d.bar.x 1 Bullet-proof >>> EasyDict({}) {} >>> EasyDict(d={}) {} >>> EasyDict(None) {} >>> d = {'a': 1} >>> EasyDict(**d) {'a': 1} >>> EasyDict((('a', 1), ('b', 2))) {'a': 1, 'b': 2} Set attributes >>> d = EasyDict() >>> d.foo = 3 >>> d.foo 3 >>> d.bar = {'prop': 'value'} >>> d.bar.prop 'value' >>> d {'foo': 3, 'bar': {'prop': 'value'}} >>> d.bar.prop = 'newer' >>> d.bar.prop 'newer' Values extraction >>> d = EasyDict({'foo':0, 'bar':[{'x':1, 'y':2}, {'x':3, 'y':4}]}) >>> isinstance(d.bar, list) True >>> from operator import attrgetter >>> list(map(attrgetter('x'), d.bar)) [1, 3] >>> list(map(attrgetter('y'), d.bar)) [2, 4] >>> d = EasyDict() >>> list(d.keys()) [] >>> d = EasyDict(foo=3, bar=dict(x=1, y=2)) >>> d.foo 3 >>> d.bar.x 1 Still like a dict though >>> o = EasyDict({'clean':True}) >>> list(o.items()) [('clean', True)] And like a class >>> class Flower(EasyDict): ... power = 1 ... mean = {} ... color = {"r": 100, "g": 0, "b": 0} ... >>> f = Flower() >>> f.power 1 >>> f.color.r 100 >>> f.mean.x = 10 >>> f.mean.x 10 >>> f = Flower({'height': 12}) >>> f.height 12 >>> f['power'] 1 >>> sorted(f.keys()) ['color', 'height', 'mean', 'power'] update and pop items >>> d = EasyDict(a=1, b='2') >>> e = EasyDict(c=3.0, a=9.0) >>> d.update(e) >>> d.c 3.0 >>> d['c'] 3.0 >>> d.get('c') 3.0 >>> d.update(a=4, b=4) >>> d.b 4 >>> d.pop('a') 4 >>> d.a Traceback (most recent call last): ... AttributeError: 'EasyDict' object has no attribute 'a' """ def __init__(self, d=None, **kwargs): if d is None: d = {} else: d = dict(d) if kwargs: d.update(**kwargs) for k, v in d.items(): setattr(self, k, v) # Class attributes for k in self.__class__.__dict__.keys(): if not (k.startswith('__') and k.endswith('__')) and not k in ('update', 'pop'): setattr(self, k, getattr(self, k)) def __setattr__(self, name, value): if isinstance(value, (list, tuple)): value = [self.__class__(x) if isinstance(x, dict) else x for x in value] elif isinstance(value, dict) and not isinstance(value, EasyDict): value = EasyDict(value) super(EasyDict, self).__setattr__(name, value) super(EasyDict, self).__setitem__(name, value) __setitem__ = __setattr__ def update(self, e=None, **f): d = e or dict() d.update(f) for k in d: setattr(self, k, d[k]) def pop(self, k, d=None): delattr(self, k) return super(EasyDict, self).pop(k, d) if __name__ == "__main__": import doctest doctest.testmod() ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1698102092.407586 easydict-1.11/easydict.egg-info/0000755000076700000240000000000014515575514016135 5ustar00mathieustaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698102092.0 easydict-1.11/easydict.egg-info/PKG-INFO0000644000076700000240000000762414515575514017243 0ustar00mathieustaffMetadata-Version: 2.1 Name: easydict Version: 1.11 Summary: Access dict values as attributes (works recursively). Home-page: https://github.com/makinacorpus/easydict Download-URL: http://pypi.python.org/pypi/easydict/ Author: Mathieu Leplatre Author-email: mathieu.leplatre@makina-corpus.com License: LGPL-3.0 Keywords: Tools Classifier: Topic :: Utilities Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Intended Audience :: Developers Classifier: Development Status :: 5 - Production/Stable Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3) Classifier: Programming Language :: Python :: 2.5 Classifier: Programming Language :: Python :: 3.6 License-File: LICENSE .. image:: https://img.shields.io/pypi/v/easydict.svg :target: https://pypi.python.org/pypi/easydict .. image:: https://img.shields.io/pypi/dm/easydict.svg :target: https://pypi.python.org/pypi/easydict ======== Easydict ======== *EasyDict* allows to access dict values as attributes (works recursively). A Javascript-like properties dot notation for python dicts. INSTALL ======= :: pip install easydict USAGE ===== :: >>> from easydict import EasyDict as edict >>> d = edict({'foo':3, 'bar':{'x':1, 'y':2}}) >>> d.foo 3 >>> d.bar.x 1 >>> d = edict(foo=3) >>> d.foo 3 Very useful when exploiting parsed JSON content ! :: >>> from easydict import EasyDict as edict >>> from simplejson import loads >>> j = """{ "Buffer": 12, "List1": [ {"type" : "point", "coordinates" : [100.1,54.9] }, {"type" : "point", "coordinates" : [109.4,65.1] }, {"type" : "point", "coordinates" : [115.2,80.2] }, {"type" : "point", "coordinates" : [150.9,97.8] } ] }""" >>> d = edict(loads(j)) >>> d.Buffer 12 >>> d.List1[0].coordinates[1] 54.9 Can set attributes as easily as getting them : :: >>> d = EasyDict() >>> d.foo = 3 >>> d.foo 3 It is still a ``dict`` ! :: >>> d = EasyDict(log=False) >>> d.debug = True >>> d.items() [('debug', True), ('log', False)] Instance and class attributes are accessed like usual objects... :: >>> class Flower(EasyDict): ... power = 1 ... >>> f = Flower({'height': 12}) >>> f.power 1 >>> f['power'] 1 LICENSE ======= * Lesser GNU Public License AUTHORS ======= * Mathieu Leplatre |makinacom|_ .. |makinacom| image:: http://depot.makina-corpus.org/public/logo.gif .. _makinacom: http://www.makina-corpus.com Similar tools ============= * `TreeDict `_, a fast and full-featured dict-like tree container. * `addict `_ ========= CHANGELOG ========= 1.11 (2023-10-24) ================= - Fix #39: RecursionError when dict in class member (#41) - Minor changes in README 1.10 (2022-09-28) ================= * Make tests compatible with python2 and python3 (thanks @JackLangerman) * Dictify input * Fix license metadata 1.9 (2018-10-18) ================ * Fix issue #3 that update and pop now work correctly on EasyDicts. 1.8 (2018-08-17) ================ * Update package classifiers. 1.7 (2017-04-27) ================ * Prevent copying sub-EasyDicts on assignment to fix unpickling (#7, thanks @Chronos-Sk) 1.6 (2015-01-27) ================ * Allow setting attributes via setting items (thanks phivos) 1.5 (2014-08-07) ================ * Allow subclassing using self instead of class name (thanks Steve Engledow) 1.4 (2011-03-13) ================ * Access class attributes like instance attributes 1.3 (2012-02-08) ================ * Better documentation and tests 1.2 (2011-06-08) ================ * Fix inclusion of README 1.1 (2012-04-21) ================ * Switch to distutils2 1.0 (2011-04-18) ================ * Initial working version ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698102092.0 easydict-1.11/easydict.egg-info/SOURCES.txt0000644000076700000240000000034314515575514020021 0ustar00mathieustaffCHANGES LICENSE MANIFEST.in README.rst setup.py easydict/__init__.py easydict.egg-info/PKG-INFO easydict.egg-info/SOURCES.txt easydict.egg-info/dependency_links.txt easydict.egg-info/not-zip-safe easydict.egg-info/top_level.txt././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698102092.0 easydict-1.11/easydict.egg-info/dependency_links.txt0000644000076700000240000000000114515575514022203 0ustar00mathieustaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1664364061.0 easydict-1.11/easydict.egg-info/not-zip-safe0000644000076700000240000000000114315027035020347 0ustar00mathieustaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698102092.0 easydict-1.11/easydict.egg-info/top_level.txt0000644000076700000240000000001114515575514020657 0ustar00mathieustaffeasydict ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1698102092.4079294 easydict-1.11/setup.cfg0000644000076700000240000000004614515575514014457 0ustar00mathieustaff[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1698101781.0 easydict-1.11/setup.py0000644000076700000240000000232014515575025014342 0ustar00mathieustaff#!/usr/bin/python # -*- coding: utf8 -*- import os from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) setup( name='easydict', version='1.11', author='Mathieu Leplatre', author_email='mathieu.leplatre@makina-corpus.com', url='https://github.com/makinacorpus/easydict', download_url="http://pypi.python.org/pypi/easydict/", description="Access dict values as attributes (works recursively).", long_description=open(os.path.join(here, 'README.rst')).read() + '\n\n' + open(os.path.join(here, 'CHANGES')).read(), license='LGPL-3.0', install_requires=[], packages=find_packages(), include_package_data=True, zip_safe=False, keywords=['Tools'], classifiers=['Topic :: Utilities', 'Natural Language :: English', 'Operating System :: OS Independent', 'Intended Audience :: Developers', 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)', 'Programming Language :: Python :: 2.5', 'Programming Language :: Python :: 3.6'], )