AlphaConfig
Introduction
AlphaConfig is easy to read and easy to use, which is designed for configuration.
Installation
You can install AlphaConfig by pip.
pip install AlphaConfig
APIs
init(src_dict: dict=None, path2yaml: os.PathLike=None, path2json: os.PathLike=None, read_only: bool=False, **kwargs)
Info:
Initialize a AlphaConfig instance.
Args:
src_dict (dict): Create an AlphaConfig instance from python builtin's dict, default is None.
path2yaml (os.PathLike): Create an AlphaConfig instance from a yaml file, default is None.
path2json (os.PathLike): Create an AlphaConfig instance from a json file, default is None.
read_only (bool): Set the state of AlphaConfig instance, modification is allowed only if its value is False.
kwargs (key-value pairs): Create attribute-value pairs from key-value pairs.
Example
from alphaconfig import AlphaConfig
test_dict = {
"attr_1": 1,
"attr_2": {
"attr_2_1": [2, 3],
"attr_2_2": "this is attr_2_2",
}
}
configs = AlphaConfig(test_dict, attr_3="value_3")
print(configs)
# * ATTRIBUTES *
# - attr_1: 1
# - attr_2:
# - attr_2_1: [2, 3]
# - attr_2_2: this is attr_2_2
# - attr_3: value_3
is_read_only()
Info:
Allow user to check whether an instance is read only or not.
Returns:
(bool): True if it is read only else False.
cvt2dict()
Info:
Convert an AlphaConfig instance to a python builtin's dict.
Returns:
(dict)
Examples
test_dict = {
"attr_1": 1,
"attr_2": {
"attr_2_1": [2, 3],
"attr_2_2": "this is attr_2_2",
}
}
configs = AlphaConfig(test_dict, attr_3="value_3")
print(configs.cvt2dict())
# {'attr_1': 1, 'attr_2': {'attr_2_1': [2, 3], 'attr_2_2': 'this is attr_2_2'}, 'attr_3': 'value_3'}
cvt_state(read_only: bool=None)
Info:
Convert the readable state according to the given arg.
Args:
read_only (bool): Set the readable state, if no value is given, revert the state.
Returns:
(bool): The final readable state.
keys()
Info:
Get all user-defined attributes. This method act like a python builtin's dict.
Returns:
(dict_keys)
values()
Info:
Get all user-defined values of corresponding keys. This method act like a python builtin's dict.
Returns:
(dict_values)
items()
Info:
Get all user-defined values of corresponding keys. This method act like a python builtin's dict.
Returns:
(dict_items)
iter()
AlphaConfig supports iter.
Example
test_dict = {
"attr_1": 1,
"attr_2": {
"attr_2_1": [2, 3],
"attr_2_2": "this is attr_2_2",
}
}
config = AlphaConfig(test_dict)
for it in config:
print(it)
# ('attr_1', 1)
# ('attr_2', {'attr_2_1': [2, 3], 'attr_2_2': 'this is attr_2_2'})
copy and deepcopy
AlphaConfig supports copy and deepcopy, just call copy module.
Metadata
Release files for alphaconfig 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| alphaconfig-0.0.3.tar.gz | 4.7 kB | Without provenance | Details for alphaconfig-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| alphaconfig-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for alphaconfig-0.0.3-py3-none-any.whl |
Total release size: 9.9 kB
Release files / alphaconfig-0.0.3.tar.gz
| Download URL | alphaconfig-0.0.3.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6ecbd3fe7bcc6a46f2d0e8b268b76ff1b4c967dda4d2c1863060d79047320a4
|
|
BLAKE2b-256 checksum How to use checksums |
5599587c21573ed7bc65d4ba17d9e810ebc16bf9a9807c83411e0d0f0b05a5cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Release files / alphaconfig-0.0.3-py3-none-any.whl
| Download URL | alphaconfig-0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2af0e3368e4d8daa46e21a3a0960dfb00d820966c3ccb8ae6c493c07e826edf7
|
|
BLAKE2b-256 checksum How to use checksums |
bec6944bdd6e43672855d8498db63acb1c4e2c3ba0a18cea0a22a44a68cfb947
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Security for alphaconfig 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.