From 39a1e5d88d3a865fb2a3b1f64a5d48d5530f62ee Mon Sep 17 00:00:00 2001 From: Brendan Curran-Johnson Date: Thu, 9 Apr 2015 19:57:54 -0400 Subject: [PATCH] 2.0 --- CHANGES.txt | 1 + README.rst | 60 +---------------------------------------------------- 2 files changed, 2 insertions(+), 59 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index c0ea8b7..291406d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,3 +10,4 @@ v0.5.1, 2014/07/14 -- tox for local testing, README fix, 0.5.0 no longer from th v1.0.0, 2014/08/18 -- Development Status :: 5 - Production/Stable v1.1.0, 2014/10/29 -- has_key support to match python2 dicts (by Nikolaos-Digenis Karagiannis @Digenis) v1.2.0, 2014/11/26 -- Happy U.S. Thanksgiving, now you can pickle AttrDict! (by @jtratner), bugfix: default_factory will no longer be erroneously called when accessing private attributes. +v2.0, 2015/04/09 -- Happy PyCon. An almost-complete rewrite. Hopefully in a good way diff --git a/README.rst b/README.rst index d5e4ec8..dc76c4c 100644 --- a/README.rst +++ b/README.rst @@ -38,11 +38,6 @@ Or from Github:: $ cd AttrDict $ python setup.py install -Documentation -============= - -Documentation is available at http://attrdict.readthedocs.org/en/latest/ - Basic Usage =========== AttrDict comes with three different classes, `AttrMap`, `AttrDict`, and @@ -146,12 +141,7 @@ AttrDefault also has a `pass_key` option that passes the supplied key to the Merging ------- -All three Attr classes - - -Merging -------- -AttrDicts can be merged with each other or other dict objects using the +All three Attr classes can be merged with eachother or other Mappings using the ``+`` operator. For conflicting keys, the right dict's value will be preferred, but in the case of two dictionary values, they will be recursively merged:: @@ -200,54 +190,6 @@ When merging an AttrDict with another mapping, this behavior will be disabled if at least one of the merged items is an AttrDict that has set ``recursive`` to ``False``. -DefaultDict -=========== - -AttrDict supports defaultdict-style automatic creation of attributes:: - - > adict = AttrDict(default_factory=list) - > adict.foo - [] - -Furthermore, if ``pass_key=True``, then the key will be passed to the function -used when creating the value:: - - > adict = AttrDict(default_factory=lambda value: value.upper(), pass_key=True) - > adict.foo - 'FOO' - -load -==== -A common usage for AttrDict is to use it in combination with settings files to -create hierarchical settings. attrdict comes with a load function to make this -easier:: - - from attrdict import load - - settings = load('settings.json') - -By default, ``load`` uses ``json.load`` to load the settings file, but this can -be overridden by passing ``load_function=YOUR_LOAD_FUNCTION``. - -``load`` supports loading from multiple files at once. This allows for -overriding of default settings, e.g.:: - - from attrdict import load - from yaml import safe_load - - # config.yaml = - # emergency: - # email: everyone@example.com - # message: Something went wrong - # - # user.yaml = - # emergency: - # email: user@example.com - settings = load('config.yaml', 'user.yaml', load_function=safe_load) - - assert settings.email == 'user@example.com' - assert settings.message == 'Something went wrong' - License ======= AttrDict is released under a MIT license.