Updated version, README and CHANGELOG.

This commit is contained in:
Fabio Caccamo 2019-10-14 14:47:49 +02:00
parent 8334993d96
commit 07028bf984
4 changed files with 51 additions and 11 deletions

View File

@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.11.0](https://github.com/fabiocaccamo/python-benedict/releases/tag/0.11.0) - 2019-10-14
- Added `query-string` I/O support.
- Added `unique` utility method.
- Added urldecode, padding fix and `format=None` support to `io_util.decode_base64` utility.
- Refactored `benedict` class and utilies.
## [0.10.0](https://github.com/fabiocaccamo/python-benedict/releases/tag/0.10.0) - 2019-10-03
- Added `base64` I/O support.
- Added `invert` utility method.

View File

@ -9,7 +9,7 @@
[![License](https://img.shields.io/pypi/l/python-benedict.svg)](https://img.shields.io/pypi/l/python-benedict.svg)
# python-benedict
python-benedict is a dict subclass with **keypath** support, **I/O** shortcuts (Base64, JSON, TOML, XML, YAML) and many **utilities**... for humans, obviously.
python-benedict is a dict subclass with **keypath** support, **I/O** shortcuts (Base64, JSON, TOML, XML, YAML, query-string) and many **utilities**... for humans, obviously.
## Index
- [Features](#features)
@ -36,14 +36,17 @@ python-benedict is a dict subclass with **keypath** support, **I/O** shortcuts (
- [`remove`](#remove)
- [`subset`](#subset)
- [`swap`](#swap)
- [`unique`](#unique)
- [I/O](#io)
- [`from_base64`](#from_base64)
- [`from_json`](#from_json)
- [`from_query_string`](#from_query_string)
- [`from_toml`](#from_toml)
- [`from_xml`](#from_xml)
- [`from_yaml`](#from_yaml)
- [`to_base64`](#to_base64)
- [`to_json`](#to_json)
- [`to_query_string`](#to_query_string)
- [`to_toml`](#to_toml)
- [`to_xml`](#to_xml)
- [`to_yaml`](#to_yaml)
@ -72,7 +75,7 @@ python-benedict is a dict subclass with **keypath** support, **I/O** shortcuts (
## Features
- Full **keypath** support *(using the dot syntax by default)*
- Easy **I/O operations** with most common formats: `Base64`, `JSON`, `TOML`, `XML`, `YAML`
- Easy **I/O operations** with most common formats: `Base64`, `JSON`, `TOML`, `XML`, `YAML`, `query-string`
- Many **utility** and **parse methods** to retrieve data as needed *(all methods listed below)*
- Well **tested**, check the badges ;)
- 100% **backward-compatible** *(you can replace existing dicts without pain)*
@ -97,7 +100,7 @@ d = benedict()
# or cast an existing dict
d = benedict(existing_dict)
# or create from data source (filepath, url or data-string) in a supported format (base64, json, toml, xml, yaml)
# or create from data source (filepath, url or data-string) in a supported format (base64, json, toml, xml, yaml, query-string)
d = benedict('https://localhost:8000/data.json')
# or in a Django view
@ -241,7 +244,7 @@ d.merge(a, b, c)
```python
# Move an item from key_src to key_dst.
# It can be used to rename a key.
# If key_dst exists, it will be overwritten.
# If key_dst exists, its value will be overwritten.
d.move('a', 'b')
```
@ -268,6 +271,13 @@ s = d.subset(['firstname', 'lastname', 'email'])
d.swap('firstname', 'lastname')
```
- #### unique
```python
# Remove duplicated values from the dict.
d.unique()
```
### I/O
It is possible to create a `benedict` instance directly from data source (filepath, url or data-string) by passing the data source as first argument in the constructor.
@ -283,15 +293,17 @@ d = benedict('https://localhost:8000/data.xml')
d = benedict('{"a": 1, "b": 2, "c": 3, "x": 7, "y": 8, "z": 9}')
```
These methods simplify I/O operations with most common formats: `base64`, `json`, `toml`, `xml`, `yaml`
These methods simplify I/O operations with most common formats: `base64`, `json`, `toml`, `xml`, `yaml`, `query-string`
- #### from_base64
```python
# Try to load/decode a base64 encoded data and return it as benedict instance.
# Accept as first argument: url, filepath or data-string.
# It's possible to choose the format used under the hood ('json', 'toml', 'xml', 'yaml') default 'json'.
# It's possible to pass decoder specific options using kwargs.
# A ValueError is raised in case of failure.
d = benedict.from_base64(s, **kwargs)
d = benedict.from_base64(s, format='json', **kwargs)
```
- #### from_json
@ -314,6 +326,15 @@ d = benedict.from_json(s, **kwargs)
d = benedict.from_toml(s, **kwargs)
```
- #### from_query_string
```python
# Try to load/decode a query-string and return it as benedict instance.
# Accept as first argument: url, filepath or data-string.
# A ValueError is raised in case of failure.
d = benedict.from_query_string(s, **kwargs)
```
- #### from_xml
```python
@ -338,8 +359,10 @@ d = benedict.from_yaml(s, **kwargs)
```python
# Return the dict instance encoded in base64 format and optionally save it at the specified filepath.
# It's possible to choose the format used under the hood ('json', 'toml', 'xml', 'yaml') default 'json'.
# It's possible to pass decoder specific options using kwargs.
# A ValueError is raised in case of failure.
s = d.to_base64(filepath='', **kwargs)
s = d.to_base64(filepath='', format='json', **kwargs)
```
- #### to_json
@ -351,6 +374,14 @@ s = d.to_base64(filepath='', **kwargs)
s = d.to_json(filepath='', **kwargs)
```
- #### to_query_string
```python
# Return the dict instance as query-string and optionally save it at the specified filepath.
# A ValueError is raised in case of failure.
s = d.to_query_string(filepath='', **kwargs)
```
- #### to_toml
```python

View File

@ -2,8 +2,8 @@
__author__ = 'Fabio Caccamo'
__copyright__ = 'Copyright (c) 2019 Fabio Caccamo'
__description__ = 'python-benedict is a dict subclass with keypath support, I/O shortcuts (json, toml, xml, yaml) and many utilities... for humans, obviously.'
__description__ = 'python-benedict is a dict subclass with keypath support, I/O shortcuts (Base64, JSON, TOML, XML, YAML, query-string) and many utilities... for humans, obviously.'
__email__ = 'fabio.caccamo@gmail.com'
__license__ = 'MIT'
__title__ = 'benedict'
__version__ = '0.10.0'
__version__ = '0.11.0'

View File

@ -34,8 +34,11 @@ setup(
github_url, package_name, __version__),
keywords=[
'python', 'dictionary', 'dict', 'subclass', 'extended',
'benedict', 'io', 'keypath', 'parse', 'utility', 'data',
'base64', 'json', 'querystring', 'toml', 'yaml', 'xml',
'benedict', 'io', 'read', 'write', 'parse', 'keypath',
'utility', 'data', 'base64', 'json', 'query-string',
'toml', 'xml', 'yaml', 'clean', 'clone', 'deepclone',
'deepupdate', 'dump', 'filter', 'flatten', 'invert',
'merge', 'move', 'remove', 'subset', 'swap', 'unique',
],
install_requires=[
'ftfy==4.4.3;python_version<"3.4"',