Skip to content

Commit

Permalink
Fixed merge conflicts in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Fison committed Jan 30, 2021
1 parent d76cb27 commit fc45a52
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
42 changes: 3 additions & 39 deletions cleverdict.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Metadata-Version: 2.1
Name: cleverdict
Version: 1.8.0
Version: 1.8.1
Summary: A JSON-friendly data structure which allows both object attributes and dictionary keys and values to be used simultaneously and interchangeably.
Home-page: https://github.com/Pfython/cleverdict
Author: Peter Fison
Author-email: [email protected]
License: MIT License
Download-URL: https://github.com/Pfython/cleverdict/archive/1.8.0.tar.gz
Description: # CleverDict
Download-URL: https://github.com/Pfython/cleverdict/archive/1.8.1.tar.gz
Description: # `CleverDict`
<p align="center">
<a href="https://pypi.python.org/pypi/cleverdict"><img alt="PyPI" src="https://img.shields.io/pypi/v/cleverdict.svg"></a>
<a href="https://pypi.python.org/pypi/cleverdict"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/cleverdict.svg"></a>
Expand Down Expand Up @@ -36,43 +36,12 @@ Description: # CleverDict
10. [CONTRIBUTING](#10.-CONTRIBUTING)
11. [CREDITS](#11.-CREDITS)

<<<<<<< HEAD
=======
![cleverdict cartoon](https://raw.githubusercontent.com/PFython/cleverdict/master/cleverdict%20cartoon.png)
>>>>>>> 3c72d5ee6bb4bd629a09684369050c9e7f2cc2fb

## 1. OVERVIEW

`CleverDict` is a hybrid Python data class which allows both `object.attribute` and `dictionary['key']` notation to be used simultaneously and interchangeably. It's particularly handy when your code is mainly object-orientated but you want a 'DRY' and extensible way to import data in json/dictionary/list format into your objects... or vice versa... without having to write extra code just to handle the translation.

<<<<<<< HEAD
Python dictionaries are simple yet powerful, but many people find `object.attribute` syntax easier to type and more intuitive to read, so why not have the best of both worlds?
=======
```CleverDict``` also calls a ```.save``` method whenever an attribute or dictionary value is created or changed. Initially the ```.save```method does nothing, but you can overwrite it with your own function to do useful things automatically every time an attribute changes in future e.g. pickle, encode, encrypt, serialise, save data to a config file or database, upload to the cloud etc. No more slavishly writing a call to your own "save" or "update" function every... single... time...

The other main feature of `CleverDict` is that it supports **Aliases** while retaining the original keys/attributes. This is really handy for data mapping e.g. taking an API response and making it play nicely with your own data structures.

Read on to find out more...


## 2. INSTALLATION
No dependencies. Very lightweight:

pip install cleverdict

or to cover all bases...

python -m pip install cleverdict --upgrade




## 3. BASIC USE

```CleverDict``` objects behave like normal Python dictionaries, but with the convenience of immediately offering read and write access to their data (keys and values) using the ```object.attribute``` syntax, which many people find easier to type and more intuitive to read and understand.

You can create a ```CleverDict``` object in exactly the same way as a regular Python dictionary:
>>>>>>> 3c72d5ee6bb4bd629a09684369050c9e7f2cc2fb

>>> from cleverdict import CleverDict
>>> x = CleverDict({'total':6, 'usergroup': "Knights of Ni"})
Expand Down Expand Up @@ -282,12 +251,7 @@ Description: # CleverDict
>>> x
CleverDict({7: 'Seven'}, _aliases={'_7': 7}, _vars={})

<<<<<<< HEAD
`CleverDict` keeps the original dictionary keys and values unchanged and remembers any normalised attribute names as aliases in `._aliases`. You can add further aliases with `.add_alias()`:

=======
```CleverDict``` keeps the original dictionary keys and values unchanged and remembers any normalised attribute names as aliases in ```._aliases```. You can add or delete further aliases with ```.add_alias``` and ```.delete_alias```, but the original dictionary key will never be deleted, even if all aliases and attributes are removed:
>>>>>>> 3c72d5ee6bb4bd629a09684369050c9e7f2cc2fb

>>> x.add_alias(7, "NumberSeven")
>>> x.add_alias(7, "zeven")
Expand Down
2 changes: 1 addition & 1 deletion cleverdict/cleverdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Change log
==========
version 1.8
version 1.8.1
---------------------------
Added to_json() and from_json()
Added to_lines() and from_lines()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
HERE = Path(__file__).parent
NAME = "cleverdict"
GITHUB_ID = "Pfython"
VERSION = "1.8.0"
VERSION = "1.8.1"
DESCRIPTION = "A JSON-friendly data structure which allows both object attributes and dictionary keys and values to be used simultaneously and interchangeably."
LICENSE = "MIT License"
AUTHOR = "Peter Fison"
Expand Down

0 comments on commit fc45a52

Please sign in to comment.