use yaml config easy
Project description
abcDict
example
# abctest.yaml
path: ${ALLUSERSPROFILE}
info:
none1: ''
none2: None
name: ${name}
name_default: ${name|default:msbrm}
age: ${age}
age_default: ${age|default:18}
age_default_int: ${age|default:18|type:int}
info_str: 我是name:${name},name_default:${name|default:$<name>},今年刚满age:${age},age_default:${age|default:18}岁
info_str2: ${HOME}xxxxxxx${age|default:18|type:int}xxxxxxx${HOME}
file_path: /home/${FILE|default:abc}/abc.test
# abctest.py
import sys
from pathlib import Path
FILE_PATH = Path(__file__)
sys.path.append(str(FILE_PATH.parent.parent))
from src import AbcDict
yaml_file = FILE_PATH.with_suffix('.yaml')
abcDict = AbcDict(yaml_file)
print(abcDict.path)
print(abcDict.info.age_default_int)
print(type(abcDict.info.age_default_int))
print(abcDict)
abcDict.dump(yaml_file.with_stem('save')) # save as save.yaml
# cmd output
> python .\test\abctest.py
C:\ProgramData
18
<class 'int'>
{'path': 'C:\\ProgramData', 'info': {'none1': '', 'none2': 'None', 'name': None, 'name_default': 'msbrm', 'age': None, 'age_default': '18', 'age_default_int': 18}, 'info_str': '我是name:None,name_default:$<name>,今年刚满age:None,age_default:18岁', 'info_str2': 'C:\\Users\\Administratorxxxxxxx18xxxxxxxC:\\Users\\Administrator', 'file_path': '/home/abc/abc.test'}
# save.yaml
file_path: /home/abc/abc.test
info:
age: null
age_default: '18'
age_default_int: 18
name: null
name_default: msbrm
none1: ''
none2: None
info_str: 我是name:None,name_default:$<name>,今年刚满age:None,age_default:18岁
info_str2: C:\Users\Administratorxxxxxxx18xxxxxxxC:\Users\Administrator
path: C:\ProgramData
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
abcdict-0.0.6.tar.gz
(4.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file abcdict-0.0.6.tar.gz.
File metadata
- Download URL: abcdict-0.0.6.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
218105cb634901980296fcdaf12b176252bbcbe5e3b3df7630b4a85b5ab97b18
|
|
| MD5 |
fb7dc455cc21330a3208aa54312dd2c8
|
|
| BLAKE2b-256 |
304ef6845cc899fbe638e55afae98b78c678cfa47403ef07db1f2aecbceb8b64
|
File details
Details for the file abcDict-0.0.6-py3-none-any.whl.
File metadata
- Download URL: abcDict-0.0.6-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c095031df6e8cfd9365b99d17252ef105c78797bfd96cbd2589b0f7ef7e1806c
|
|
| MD5 |
a44e9caf55016be4ced01679a7a1772c
|
|
| BLAKE2b-256 |
5b0d376f4099c2da525decbfcdf97eb5ab360cccb8d35aa43d08520523edd1e2
|