Skip to content

Commit 07028bf

Browse files
committed
Updated version, README and CHANGELOG.
1 parent 8334993 commit 07028bf

4 files changed

Lines changed: 51 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.11.0](https://github.com/fabiocaccamo/python-benedict/releases/tag/0.11.0) - 2019-10-14
8+
- Added `query-string` I/O support.
9+
- Added `unique` utility method.
10+
- Added urldecode, padding fix and `format=None` support to `io_util.decode_base64` utility.
11+
- Refactored `benedict` class and utilies.
12+
713
## [0.10.0](https://github.com/fabiocaccamo/python-benedict/releases/tag/0.10.0) - 2019-10-03
814
- Added `base64` I/O support.
915
- Added `invert` utility method.

README.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![License](https://img.shields.io/pypi/l/python-benedict.svg)](https://img.shields.io/pypi/l/python-benedict.svg)
1010

1111
# python-benedict
12-
python-benedict is a dict subclass with **keypath** support, **I/O** shortcuts (Base64, JSON, TOML, XML, YAML) and many **utilities**... for humans, obviously.
12+
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.
1313

1414
## Index
1515
- [Features](#features)
@@ -36,14 +36,17 @@ python-benedict is a dict subclass with **keypath** support, **I/O** shortcuts (
3636
- [`remove`](#remove)
3737
- [`subset`](#subset)
3838
- [`swap`](#swap)
39+
- [`unique`](#unique)
3940
- [I/O](#io)
4041
- [`from_base64`](#from_base64)
4142
- [`from_json`](#from_json)
43+
- [`from_query_string`](#from_query_string)
4244
- [`from_toml`](#from_toml)
4345
- [`from_xml`](#from_xml)
4446
- [`from_yaml`](#from_yaml)
4547
- [`to_base64`](#to_base64)
4648
- [`to_json`](#to_json)
49+
- [`to_query_string`](#to_query_string)
4750
- [`to_toml`](#to_toml)
4851
- [`to_xml`](#to_xml)
4952
- [`to_yaml`](#to_yaml)
@@ -72,7 +75,7 @@ python-benedict is a dict subclass with **keypath** support, **I/O** shortcuts (
7275

7376
## Features
7477
- Full **keypath** support *(using the dot syntax by default)*
75-
- Easy **I/O operations** with most common formats: `Base64`, `JSON`, `TOML`, `XML`, `YAML`
78+
- Easy **I/O operations** with most common formats: `Base64`, `JSON`, `TOML`, `XML`, `YAML`, `query-string`
7679
- Many **utility** and **parse methods** to retrieve data as needed *(all methods listed below)*
7780
- Well **tested**, check the badges ;)
7881
- 100% **backward-compatible** *(you can replace existing dicts without pain)*
@@ -97,7 +100,7 @@ d = benedict()
97100
# or cast an existing dict
98101
d = benedict(existing_dict)
99102

100-
# or create from data source (filepath, url or data-string) in a supported format (base64, json, toml, xml, yaml)
103+
# or create from data source (filepath, url or data-string) in a supported format (base64, json, toml, xml, yaml, query-string)
101104
d = benedict('https://localhost:8000/data.json')
102105

103106
# or in a Django view
@@ -241,7 +244,7 @@ d.merge(a, b, c)
241244
```python
242245
# Move an item from key_src to key_dst.
243246
# It can be used to rename a key.
244-
# If key_dst exists, it will be overwritten.
247+
# If key_dst exists, its value will be overwritten.
245248
d.move('a', 'b')
246249
```
247250

@@ -268,6 +271,13 @@ s = d.subset(['firstname', 'lastname', 'email'])
268271
d.swap('firstname', 'lastname')
269272
```
270273

274+
- #### unique
275+
276+
```python
277+
# Remove duplicated values from the dict.
278+
d.unique()
279+
```
280+
271281
### I/O
272282

273283
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')
283293
d = benedict('{"a": 1, "b": 2, "c": 3, "x": 7, "y": 8, "z": 9}')
284294
```
285295

286-
These methods simplify I/O operations with most common formats: `base64`, `json`, `toml`, `xml`, `yaml`
296+
These methods simplify I/O operations with most common formats: `base64`, `json`, `toml`, `xml`, `yaml`, `query-string`
287297

288298
- #### from_base64
289299

290300
```python
291301
# Try to load/decode a base64 encoded data and return it as benedict instance.
292302
# Accept as first argument: url, filepath or data-string.
303+
# It's possible to choose the format used under the hood ('json', 'toml', 'xml', 'yaml') default 'json'.
304+
# It's possible to pass decoder specific options using kwargs.
293305
# A ValueError is raised in case of failure.
294-
d = benedict.from_base64(s, **kwargs)
306+
d = benedict.from_base64(s, format='json', **kwargs)
295307
```
296308

297309
- #### from_json
@@ -314,6 +326,15 @@ d = benedict.from_json(s, **kwargs)
314326
d = benedict.from_toml(s, **kwargs)
315327
```
316328

329+
- #### from_query_string
330+
331+
```python
332+
# Try to load/decode a query-string and return it as benedict instance.
333+
# Accept as first argument: url, filepath or data-string.
334+
# A ValueError is raised in case of failure.
335+
d = benedict.from_query_string(s, **kwargs)
336+
```
337+
317338
- #### from_xml
318339

319340
```python
@@ -338,8 +359,10 @@ d = benedict.from_yaml(s, **kwargs)
338359

339360
```python
340361
# Return the dict instance encoded in base64 format and optionally save it at the specified filepath.
362+
# It's possible to choose the format used under the hood ('json', 'toml', 'xml', 'yaml') default 'json'.
363+
# It's possible to pass decoder specific options using kwargs.
341364
# A ValueError is raised in case of failure.
342-
s = d.to_base64(filepath='', **kwargs)
365+
s = d.to_base64(filepath='', format='json', **kwargs)
343366
```
344367

345368
- #### to_json
@@ -351,6 +374,14 @@ s = d.to_base64(filepath='', **kwargs)
351374
s = d.to_json(filepath='', **kwargs)
352375
```
353376

377+
- #### to_query_string
378+
379+
```python
380+
# Return the dict instance as query-string and optionally save it at the specified filepath.
381+
# A ValueError is raised in case of failure.
382+
s = d.to_query_string(filepath='', **kwargs)
383+
```
384+
354385
- #### to_toml
355386

356387
```python

benedict/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
__author__ = 'Fabio Caccamo'
44
__copyright__ = 'Copyright (c) 2019 Fabio Caccamo'
5-
__description__ = 'python-benedict is a dict subclass with keypath support, I/O shortcuts (json, toml, xml, yaml) and many utilities... for humans, obviously.'
5+
__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.'
66
__email__ = 'fabio.caccamo@gmail.com'
77
__license__ = 'MIT'
88
__title__ = 'benedict'
9-
__version__ = '0.10.0'
9+
__version__ = '0.11.0'

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
github_url, package_name, __version__),
3535
keywords=[
3636
'python', 'dictionary', 'dict', 'subclass', 'extended',
37-
'benedict', 'io', 'keypath', 'parse', 'utility', 'data',
38-
'base64', 'json', 'querystring', 'toml', 'yaml', 'xml',
37+
'benedict', 'io', 'read', 'write', 'parse', 'keypath',
38+
'utility', 'data', 'base64', 'json', 'query-string',
39+
'toml', 'xml', 'yaml', 'clean', 'clone', 'deepclone',
40+
'deepupdate', 'dump', 'filter', 'flatten', 'invert',
41+
'merge', 'move', 'remove', 'subset', 'swap', 'unique',
3942
],
4043
install_requires=[
4144
'ftfy==4.4.3;python_version<"3.4"',

0 commit comments

Comments
 (0)