@@ -8,6 +8,7 @@ MAIN FEATURES
88* Access OOP or subscriptable, which means that you can iterate the config object items
99* Runtime validation using [ schema] ( https://github.com/keleshev/schema )
1010* Automatic environment variables interpolation
11+ * Automatic parser selecting by config file extension
1112
1213HOW TO INSTALL
1314---------------------------
@@ -19,14 +20,22 @@ pip install python-config-parser
1920
2021HOW TO USE
2122---------------------------
23+ First of all the config file will look for default config files if you do not pass your own config file for this.
24+
25+ The default config directory is ./config(if you do not pass the config directory of your preference) assuming your current directory.
26+
27+ The default config files names are -> (config.json, config.yaml, config.yml)
28+
29+
30+
2231
2332The Schema validation.
2433
25- You may use or not schema validation, if you want to use it, it will validate your whole config object before returning it.
34+ You may use or not schema validation, if you want to use it, it will validate your whole config object before returning it.
2635
27- If you don't want to use it, it won't validate the config object before returning that, and it may generate runtime access inconsistencies.
36+ If you don't want to use it, it won't validate the config object before returning that, and it may generate runtime access inconsistencies.
2837
29- How to use schema
38+ How to use schema
3039
3140``` python
3241from schema import Use, And
6170 - ip : 192.168.0.11
6271 timeout : 100
6372` ` `
73+ This config file as a json would be something like:
74+
75+ ` ` ` json
76+ {
77+ " core " : {
78+ " random_env_variable " : " ${RANDOM_ENV_VARIABLE}" ,
79+ " logging " : {
80+ " format " : " [%(asctime)s][%(levelname)s]: %(message)s" ,
81+ " date_fmt " : " %d-%b-%y %H:%M:%S"
82+ },
83+ " allowed_clients " : [
84+ {
85+ " ip " : " 192.168.0.10" ,
86+ " timeout " : 60
87+ },
88+ {
89+ " ip " : " 192.168.0.11" ,
90+ " timeout " : 100
91+ }
92+ ]
93+ }
94+ }
95+ ```
6496
6597The instance of Config Class:
6698``` python
0 commit comments