No project description provided
Project description
This is a simple program for developer to create a param-config reader. It only needs config_dict and config_file_name to analyse all param and config
for example,your py file main.py is
from movoid_config import Config
config = Config({
"param": {
"type": "string", # we will change it to a string.you can input: int,float,number,bool,true,false,list,dict,enum,kv,byte.others are all string.
"default": "ppp", # when you do not input,we will give a default value.it will make 'must' invalidate
"single": "p", # use like -p *
"full": "param", # use like --param *
"key": "param", # use like param=?
"ini": ["main", "param"], # use in config.ini
"config": True, # whether try to find and write in .ini file
"must": True, # whether you must input it ,or it will raise exception
"ask": True, # when you do not input,you can change to ask user to input it
"help": "This is param which is an example.", # show it in help text.(not done yet)
},
"check": {
"type": "true",
"false": {
"single": "f",
"full": "false"
} # when type is true,you can input -f or --false to input a false value to "check"
},
"int_list": {
"full": "list",
"type": "list",
"sub": "int" # to define type of list value
},
"int_bool_dict": {
"key": "dict",
"type": "dict",
"sub": ["int", "str"] # to define type of dict key and value
}
}, "config.ini")
print(config.param)
print(config["int_list"])
print(config["int_bool_dict"])
when you input
python main.py -p p234 --list 1,2,3 dict=1:a,2:b
you can see
p234
[1, 2, 3]
{1: 'a', 2: 'b'}
you can also use
from movoid_config import Config
config = Config({})
for i, v in config.items():
print(i, v)
for i in config.keys():
print(i)
for v in config.values():
print(v)
to traversal loop
If you use when you do not input. An error will be raised like use an unknown key in a dict.
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
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 movoid_config-1.2.7.tar.gz.
File metadata
- Download URL: movoid_config-1.2.7.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6017b9241b77f91bc0227bf74752822223de3acb1b3824c804992b453b596e80
|
|
| MD5 |
b927883b06ddccef54e9dd07a500ab99
|
|
| BLAKE2b-256 |
69847f49a7d86f794735f293ce6a847b7950e81b6596b86c3573fe5c2b444f12
|
File details
Details for the file movoid_config-1.2.7-py3-none-any.whl.
File metadata
- Download URL: movoid_config-1.2.7-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49e3ca7ba055aaff22dec79041cdb89b5c9d09e3c5e5a18ef4b770d8aba59f37
|
|
| MD5 |
0168288d6376f06da062deb1d92a55ec
|
|
| BLAKE2b-256 |
34b4c8bebac44a3ff5bedaf75cc1201f8cb791351ad5c43e8605fe4e60b187f0
|