Removed README.rst

This commit is contained in:
Fabio Caccamo 2019-07-03 14:26:59 +02:00
parent b39835536c
commit d5513c2420
2 changed files with 8 additions and 221 deletions

View File

@ -1,219 +0,0 @@
|Build Status| |codecov| |Codacy| |Requirements Status|
|PyPI version| |PyPI downloads| |Py versions| |License|
python-benedict
===============
The Python dictionary for humans dealing with evil/complex data.
Features
--------
- Full **keypath** support *(using the dot syntax)*
- Many **utility** and **parse methods** to retrieve data as needed *(all methods listed below)*
- Give **benediction to dict objects** before they are returned *(they receive benedict casting)*
- 100% **backward-compatible** *(you can replace existing dicts without pain)*
Requirements
------------
- Python 2.7, 3.4, 3.5, 3.6, 3.7
Installation
------------
- Run ``pip install python-benedict``
Testing
-------
- Run ``tox`` / ``python setup.py test``
Usage
-----
``benedict`` is a dict subclass, so it is possible to use it as a normal
dict *(you can just cast an existing dict)*.
Basic get/set using keypath
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
from benedict import benedict
d = benedict()
d['profile.firstname'] = 'Fabio'
d['profile.lastname'] = 'Caccamo'
print(d) # -> { 'profile':{ 'firstname':'Fabio', 'lastname':'Caccamo' } }
print(d['profile']) # -> { 'firstname':'Fabio', 'lastname':'Caccamo' }
print('profile.lastname' in d) # -> True
API
^^^^^^^^^^^^^
.. code:: python
# Clean the current dict removing empty values: None, '', {}, [], ().
# If strings, dicts or lists flags are False, related empty values will not be deleted.
d.clean(strings=True, dicts=True, lists=True)
.. code:: python
# Return a deepcopy of the dict.
d.deepcopy()
.. code:: python
# Return a readable representation of any dict/list.
s = benedict.dump(d.keypaths())
print(s)
.. code:: python
# Return a readable representation of the dict for the given key (optional).
s = d.dump_items(key=None)
print(s)
.. code:: python
# Return a filtered dict using the given predicate function.
# Predicate function receives key, value arguments and should return a bool value.
predicate = lambda k, v: v is not None
d.filter(predicate)
.. code:: python
# Get value by key or keypath trying to return it as bool.
# Values like `1`, `true`, `yes`, `on`, `ok` will be returned as `True`.
d.get_bool(key, default=False)
.. code:: python
# Get value by key or keypath trying to return it as list of bool values.
# If separator is specified and value is a string it will be splitted.
d.get_bool_list(key, default=[], separator=',')
.. code:: python
# Get value by key or keypath trying to return it as datetime.
# If format is not specified it will be autodetected.
# If options and value is in options return value otherwise default.
d.get_datetime(key, default=None, format=None, options=[])
.. code:: python
# Get value by key or keypath trying to return it as list of datetime values.
# If separator is specified and value is a string it will be splitted.
d.get_datetime_list(key, default=[], format=None, separator=',')
.. code:: python
# Get value by key or keypath trying to return it as Decimal.
# If options and value is in options return value otherwise default.
d.get_decimal(key, default=Decimal('0.0'), options=[])
.. code:: python
# Get value by key or keypath trying to return it as list of Decimal values.
# If separator is specified and value is a string it will be splitted.
d.get_decimal_list(key, default=[], separator=',')
.. code:: python
# Get value by key or keypath trying to return it as dict.
# If value is a json string it will be automatically decoded.
d.get_dict(key, default={})
.. code:: python
# Get email by key or keypath and return it.
# If value is blacklisted it will be automatically ignored.
# If check_blacklist is False, it will be not ignored even if blacklisted.
d.get_email(key, default='', options=None, check_blacklist=True)
.. code:: python
# Get value by key or keypath trying to return it as float.
# If options and value is in options return value otherwise default.
d.get_float(key, default=0.0, options=[])
.. code:: python
# Get value by key or keypath trying to return it as list of float values.
# If separator is specified and value is a string it will be splitted.
d.get_float_list(key, default=[], separator=',')
.. code:: python
# Get value by key or keypath trying to return it as int.
# If options and value is in options return value otherwise default.
d.get_int(key, default=0, options=[])
.. code:: python
# Get value by key or keypath trying to return it as list of int values.
# If separator is specified and value is a string it will be splitted.
d.get_int_list(key, default=[], separator=',')
.. code:: python
# Get value by key or keypath trying to return it as list.
# If separator is specified and value is a string it will be splitted.
d.get_list(key, default=[], separator=',')
.. code:: python
# Get list by key or keypath and return value at the specified index.
# If separator is specified and list value is a string it will be splitted.
d.get_list_item(key, index=0, default=None, separator=',')
.. code:: python
# Get phone number by key or keypath and return a dict with different formats (e164, international, national).
# If country code is specified (alpha 2 code), it will be used to parse phone number correctly.
d.get_phonenumber(key, country_code=None, default=None)
.. code:: python
# Get value by key or keypath trying to return it as slug.
# If options and value is in options return value otherwise default.
d.get_slug(key, default='', options=[])
.. code:: python
# Get value by key or keypath trying to return it as list of slug values.
# If separator is specified and value is a string it will be splitted.
d.get_slug_list(key, default=[], separator=',')
.. code:: python
# Get value by key or keypath trying to return it as string.
# Encoding issues will be automatically fixed.
# If options and value is in options return value otherwise default.
d.get_str(key, default='', options=[])
.. code:: python
# Get value by key or keypath trying to return it as list of str values.
# If separator is specified and value is a string it will be splitted.
d.get_str_list(key, default=[], separator=',')
.. code:: python
# Return a list of all keypaths in the dict.
d.keypaths()
License
-------
Released under `MIT License <LICENSE.txt>`__.
.. |Build Status| image:: https://travis-ci.org/fabiocaccamo/python-benedict.svg?branch=master
.. |codecov| image:: https://codecov.io/gh/fabiocaccamo/python-benedict/branch/master/graph/badge.svg
.. |Codacy| image:: https://api.codacy.com/project/badge/Grade/0dbd5cc2089f4dce80a0e49e6822be3c
.. |Requirements Status| image:: https://requires.io/github/fabiocaccamo/python-benedict/requirements.svg?branch=master
.. |PyPI version| image:: https://badge.fury.io/py/python-benedict.svg
.. |PyPI downloads| image:: https://img.shields.io/pypi/dm/python-benedict.svg
.. |Py versions| image:: https://img.shields.io/pypi/pyversions/python-benedict.svg
.. |License| image:: https://img.shields.io/pypi/l/python-benedict.svg

View File

@ -10,7 +10,8 @@ exec(open('benedict/metadata.py').read())
github_url = 'https://github.com/fabiocaccamo'
package_name = 'python-benedict'
package_path = os.path.abspath(os.path.dirname(__file__))
long_description_file_path = os.path.join(package_path, 'README.rst')
long_description_file_path = os.path.join(package_path, 'README.md')
long_description_content_type = 'text/markdown'
long_description = ''
try:
with open(long_description_file_path) as f:
@ -25,6 +26,7 @@ setup(
version=__version__,
description=__description__,
long_description=long_description,
long_description_content_type=long_description_content_type,
author=__author__,
author_email=__email__,
url='{}/{}'.format(github_url, package_name),
@ -38,7 +40,11 @@ setup(
'phonenumbers',
'python-dateutil',
'python-slugify',
# 'requests',
'pyyaml',
'requests',
'six',
'toml',
'xmltodict',
],
classifiers=[
'Development Status :: 5 - Production/Stable',