Skip to main content

What's the good of that?

PyPI version Supported Python versions License

  1. Validate and transform an incoming dictionary based on schema rules
  2. Get the dictionary value and cast string representation to target data type
  3. Available types:

"object": raw object

"str": textual data

"int": integer numeric type

"float": float numeric type

"decimal": decimal numeric type

"list": list sequence type

"datetime": a datetime object is a single object containing all the information from a date object and a time object

"date": a date object represents a date (year, month and day)

"bool": boolean values are the two constant objects False and True

  1. Set default value if result is None
  2. Get the required dictionary value and cast it to data type
  3. Get the required dictionary value and raise error if value is empty

install

pip install power-dict

import

from power_dict.utils import DictUtils

Run unittest from console

python -m unittest discover -p "*_tests.py"

SchemaValidator.validate(context: dict, schema: list, sanitize_schema: bool = True) -> dict

Validation and transformation of 'context' dictionary in accordance with the rules of the scheme. See tests for examples.

DictUtils.get_value(properties: dict, key: str, **kwargs) -> object

Get the dictionary value and cast it to object. See tests for examples.

DictUtils.get_required_value(properties: dict, key: str, **kwargs) -> object

Get the required dictionary value and cast it to object. See tests for examples.

DictUtils.get_setting_by_path(properties: dict, path: str, **kwargs) -> object

Get the dictionary value and cast it to object by path. See tests for examples.

DictUtils.get_dict_property(properties: dict, key: str, default_value=None) -> object

Get the dictionary value. See tests for examples.

DictUtils.get_required_dict_property(properties: dict, key: str, required_error=None) -> object

Get the required dictionary value. See tests for examples.

DictUtils.get_str_dict_property(properties: dict, key: str, default_value='') -> str

Get the dictionary value and cast it to 'str'. See tests for examples.

DictUtils.get_required_str_dict_property(properties: dict, key: str, required_error=None) -> str

Get the required dictionary value and cast it to 'str'. See tests for examples.

DictUtils.get_int_dict_property(properties: dict, key: str, default_value=None) -> int

Get the dictionary value and cast it to 'int'. See tests for examples.

DictUtils.get_required_int_dict_property(properties: dict, key: str, required_error=None) -> int

Get the required dictionary value and cast it to 'int'. See tests for examples.

DictUtils.get_datetime_dict_property(properties: dict, key: str, default_value: datetime = None, format: str = None) -> datetime

Get the dictionary value and cast it to 'datetime'. See tests for examples. Format Codes.

DictUtils.get_required_datetime_dict_property(properties: dict, key: str, required_error=None, format: str = None) -> datetime

Get the required dictionary value and cast it to 'datetime'. See tests for examples. Format Codes.

DictUtils.get_date_dict_property(properties: dict, key: str, default_value=None, format: str = None) -> datetime.date

Get the dictionary value and cast it to 'date'. See tests for examples. Format Codes.

DictUtils.get_required_date_dict_property(properties: dict, key: str, required_error=None, format: str = None) -> datetime.date

Get the required dictionary value and cast it to 'date'. See tests for examples. Format Codes.

DictUtils.get_bool_dict_property(properties: dict, key: str, default_value=None) -> bool

Get the dictionary value and cast it to 'bool'. See tests for examples.

DictUtils.get_required_bool_dict_property(properties: dict, key: str, required_error=None) -> bool

Get the required dictionary value and cast it to 'bool'. See tests for examples.

DictUtils.get_decimal_dict_property(properties: dict, key: str, default_value=None) -> Decimal

Get the dictionary value and cast it to 'decimal'. See tests for examples.

DictUtils.get_required_decimal_dict_property(properties: dict, key: str, required_error=None) -> Decimal

Get the required dictionary value and cast it to 'decimal'. See tests for examples.

DictUtils.get_list_dict_property(properties: dict, key: str, default_value=None) -> list

Get the dictionary value and cast it to 'list'. See tests for examples.

DictUtils.get_required_list_dict_property(properties: dict, key: str, required_error=None) -> list

Get the required dictionary value and cast it to 'list'. See tests for examples.

DictUtils.get_float_dict_property(properties: dict, key: str, default_value=None) -> float

Get the dictionary value and cast it to 'float'. See tests for examples.

DictUtils.get_required_float_dict_property(properties: dict, key: str, required_error=None) -> float

Get the required dictionary value and cast it to 'float'. See tests for examples.

Metadata

Release files for power-dict 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for power-dict 0.0.13
File Size Uploaded
power_dict-0.0.13.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for power-dict 0.0.13
File Interpreter ABI Platform
power_dict-0.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / power_dict-0.0.13.tar.gz

Download URL power_dict-0.0.13.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ef1ed0a53f99b714ed67daf01b2d2c39b8e52b7afb0252ce7e3eb90037ee6c81
BLAKE2b-256 checksum
How to use checksums
96627f6e4db4e28d08cebc9d5ac59b2cdc8bfa15bd8c63dccd349396bf57c9fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

Release files / power_dict-0.0.13-py3-none-any.whl

Download URL power_dict-0.0.13-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47a6ae34d17475f1e5992cab2cf904ccd058352c6cd3e903fce61f631b7020f0
BLAKE2b-256 checksum
How to use checksums
377ace833a83e5a6230f5cf3d6b9ddda640bc58dc8d092b4f7a8e01109ced9eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.0.13 This release

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page