Name | movoid-config JSON |
Version |
1.2.6
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-10-24 16:17:18 |
maintainer | None |
docs_url | None |
author | movoid |
requires_python | None |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
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
```python
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
```shell
python main.py -p p234 --list 1,2,3 dict=1:a,2:b
```
you can see
```shell
p234
[1, 2, 3]
{1: 'a', 2: 'b'}
```
you can also use
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "movoid-config",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "movoid",
"author_email": "bobrobotsun@163.com",
"download_url": "https://files.pythonhosted.org/packages/19/22/f5a67f8b0b37c2a02766e047edd354c60bc79eb919c41a36c90a80741fcd/movoid_config-1.2.6.tar.gz",
"platform": null,
"description": "This is a simple program for developer to create a param-config reader.\nIt only needs config_dict and config_file_name to analyse all param and config\n\nfor example,your py file main.py is\n\n```python\nfrom movoid_config import Config\n\nconfig = Config({\n \"param\": {\n \"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.\n \"default\": \"ppp\", # when you do not input,we will give a default value.it will make 'must' invalidate\n \"single\": \"p\", # use like -p *\n \"full\": \"param\", # use like --param *\n \"key\": \"param\", # use like param=?\n \"ini\": [\"main\", \"param\"], # use in config.ini\n \"config\": True, # whether try to find and write in .ini file\n \"must\": True, # whether you must input it ,or it will raise exception\n \"ask\": True, # when you do not input,you can change to ask user to input it\n \"help\": \"This is param which is an example.\", # show it in help text.(not done yet)\n },\n \"check\": {\n \"type\": \"true\",\n \"false\": {\n \"single\": \"f\",\n \"full\": \"false\"\n } # when type is true,you can input -f or --false to input a false value to \"check\"\n },\n \"int_list\": {\n \"full\": \"list\",\n \"type\": \"list\",\n \"sub\": \"int\" # to define type of list value\n },\n \"int_bool_dict\": {\n \"key\": \"dict\",\n \"type\": \"dict\",\n \"sub\": [\"int\", \"str\"] # to define type of dict key and value\n }\n}, \"config.ini\")\n\nprint(config.param)\nprint(config[\"int_list\"])\nprint(config[\"int_bool_dict\"])\n\n```\n\nwhen you input \n```shell\npython main.py -p p234 --list 1,2,3 dict=1:a,2:b\n```\nyou can see \n```shell\np234\n[1, 2, 3]\n{1: 'a', 2: 'b'}\n```\n\nyou can also use \n```python\nfrom movoid_config import Config\n\nconfig = Config({})\nfor i, v in config.items():\n print(i, v)\nfor i in config.keys():\n print(i)\nfor v in config.values():\n print(v)\n```\nto traversal loop\n\nIf you use when you do not input. An error will be raised like use an unknown key in a dict.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "1.2.6",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0cacd41e1736768037772a768157dfa2439709ee705474d4b67f1be44286a093",
"md5": "ba6493cc9a330da56e186a03c2fc87ab",
"sha256": "ad03fc2bc7f327e722c230dd18db99fcf4c3bac2155b22da74fc6c18f2fc3f9d"
},
"downloads": -1,
"filename": "movoid_config-1.2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba6493cc9a330da56e186a03c2fc87ab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8039,
"upload_time": "2024-10-24T16:17:17",
"upload_time_iso_8601": "2024-10-24T16:17:17.291122Z",
"url": "https://files.pythonhosted.org/packages/0c/ac/d41e1736768037772a768157dfa2439709ee705474d4b67f1be44286a093/movoid_config-1.2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1922f5a67f8b0b37c2a02766e047edd354c60bc79eb919c41a36c90a80741fcd",
"md5": "31736578bc56201a50e8992cba88f2ed",
"sha256": "6cafd9f97656b7de4ff5d58ae87d7ada3950152315b4df2e707c97aabd05efed"
},
"downloads": -1,
"filename": "movoid_config-1.2.6.tar.gz",
"has_sig": false,
"md5_digest": "31736578bc56201a50e8992cba88f2ed",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8104,
"upload_time": "2024-10-24T16:17:18",
"upload_time_iso_8601": "2024-10-24T16:17:18.145127Z",
"url": "https://files.pythonhosted.org/packages/19/22/f5a67f8b0b37c2a02766e047edd354c60bc79eb919c41a36c90a80741fcd/movoid_config-1.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-24 16:17:18",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "movoid-config"
}