Manage nested parameters through a json file
Project description
paramctl
A Python library to match positional parameters based on a json file
When integrated properly to your script, you should be able to trigger actions like this:
script.py action object extra_parameter_1 extra_parameter_n
How does it work
You will need a Json file to define the accepted actions and objects
The Json file should look like this:
{"action1":
{ "object_a": {
"help": "Description for what action1 does to object_a",
"action": "the_name_of_your_function_for_action1_on_object_a"
},
"object_b": {
"help": "Description for what action1 does to object_b",
"action": "the_name_of_your_function_for_action1_on_object_b"
}
},
"action2":
{ "object_a": {
"help": "Description for what action2 does to object_a",
"action": "the_name_of_your_function_for_action2_on_object_a"
},
"object_y": {
"help": "Description for what action2 does to object_y",
"action": "the_name_of_your_function_for_action2_on_object_y"
}
}
}
}
On your python code (e.g.: myscript.py) add the following:
import paramctl
params = paramctl.ParameterMap("parametermap.json")
try:
print(globals()[function[0]](function[1:]))
except KeyError:
print("No function available like " + " ".join(function[:]))
, finally, create the functions defined on the Json (under "action") like this:
def get_nodes(*argv):
...
...and manage the arguments as you please.
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
paramctl-0.56.tar.gz
(2.8 kB
view details)
File details
Details for the file paramctl-0.56.tar.gz.
File metadata
- Download URL: paramctl-0.56.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76e98885e8a948b3147a77ee93d97bc92f061650c3b4f9eea092eac42269c453
|
|
| MD5 |
565bfc4c48a12ec46ade7171854f9216
|
|
| BLAKE2b-256 |
c5890e22eb934bcad12d1b1e16fe5e3a7a5817a7f57dcb7c4afcbb9f68211970
|