Name | movoid-config JSON |
Version |
1.2.4
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-08-20 17:46:56 |
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/fb/aa/3cff68212bd6821615a778d79beb3d7cea61fc2e4e7d1b50c22139d975cc/movoid_config-1.2.4.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.4",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cba9344ee68975eca0ffaf8a0a29bd165b98b02e9ff0d14ec6747c41ad024402",
"md5": "6c5e9e8e03c2017c39abfe6efde39f93",
"sha256": "08e023a4ecc7750f8a409fdb0bf4da8e537de5aef7c976a4ba6dc31e72451399"
},
"downloads": -1,
"filename": "movoid_config-1.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6c5e9e8e03c2017c39abfe6efde39f93",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8023,
"upload_time": "2024-08-20T17:46:55",
"upload_time_iso_8601": "2024-08-20T17:46:55.379371Z",
"url": "https://files.pythonhosted.org/packages/cb/a9/344ee68975eca0ffaf8a0a29bd165b98b02e9ff0d14ec6747c41ad024402/movoid_config-1.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fbaa3cff68212bd6821615a778d79beb3d7cea61fc2e4e7d1b50c22139d975cc",
"md5": "6f71d9ca739d20ad338704c42c6cd767",
"sha256": "19558541c8dd6f64597bb9136bb4a2cf661499eab8c57c1172f25f95062cd67e"
},
"downloads": -1,
"filename": "movoid_config-1.2.4.tar.gz",
"has_sig": false,
"md5_digest": "6f71d9ca739d20ad338704c42c6cd767",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8088,
"upload_time": "2024-08-20T17:46:56",
"upload_time_iso_8601": "2024-08-20T17:46:56.457496Z",
"url": "https://files.pythonhosted.org/packages/fb/aa/3cff68212bd6821615a778d79beb3d7cea61fc2e4e7d1b50c22139d975cc/movoid_config-1.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-20 17:46:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "movoid-config"
}