1- Python -config-parser
1+ python -config-parser
22===
33---
44[ ![ Tests] ( https://github.com/BrunoSilvaAndrade/python-config-parser/actions/workflows/tests.yml/badge.svg )] ( https://github.com/BrunoSilvaAndrade/python-config-parser/actions/workflows/tests.yml )
55[ ![ PyPI version] ( https://badge.fury.io/py/python-config-parser.svg )] ( https://badge.fury.io/py/python-config-parser )
66[ ![ Coverage Status] ( https://coveralls.io/repos/github/BrunoSilvaAndrade/python-config-parser/badge.svg )] ( https://coveralls.io/github/BrunoSilvaAndrade/python-config-parser )
77
8- This project was created to give you the possibility
9- of creating runtime configuration objects using json or yaml files.
8+ python-config-parser lets you create runtime configuration objects using json or yaml files.
109
1110MAIN FEATURES
1211===
@@ -20,7 +19,7 @@ MAIN FEATURES
2019HOW TO INSTALL
2120===
2221---
23- Use pip to install it.
22+ Use ` pip ` to install it.
2423
2524``` shell
2625pip install python-config-parser
@@ -29,21 +28,16 @@ pip install python-config-parser
2928HOW TO USE
3029===
3130---
32- First of all the config file will look for default config files if you do not pass your own config file for this .
31+ By default, the config file will look for the following config files in the ` .config ` directory: ` config.json ` , ` config.yaml ` , ` config.yml ` .
3332
34- The default config directory is ./config(if you do not pass the config directory of your preference) assuming your current directory.
33+ You can also pass a config directory of your preference ( assuming your current directory) .
3534
36- The default config files names are -> (config.json, config.yaml, config.yml)
37-
38-
39-
40-
41- The Schema validation.
35+ Schema validation
4236---
4337
44- You may use or not schema validation, if you want to use it, it will validate your whole config object before returning it.
38+ You may or may not use schema validation. If you want to use it, it will validate the whole config object before returning it.
4539
46- 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.
40+ If you choose not to use it, it won't validate the config object before returning it , and it may generate runtime access inconsistencies.
4741
4842How to use schema
4943
@@ -67,7 +61,7 @@ SCHEMA_CONFIG = {
6761
6862```
6963
70- The config.yml file
64+ The ` config.yml ` file
7165``` yaml
7266core :
7367 random_env_variable : ${RANDOM_ENV_VARIABLE}
8074 - ip : 192.168.0.11
8175 timeout : 100
8276` ` `
83- This config file as a json would be something like:
77+ A json config file would be something like:
8478
8579` ` ` json
8680{
@@ -105,7 +99,6 @@ This config file as a json would be something like:
10599```
106100
107101The instance of Config Class:
108-
109102``` python
110103from pyconfigparser import Configparser, ConfigError
111104import logging
@@ -119,9 +112,8 @@ except ConfigError as e:
119112
120113# to access your config you need just:
121114
122-
123- fmt = config.core.logging.format # look this, at this point I'm already using the config variable
124- date_fmt = config[' core' ][' logging' ][' date_fmt' ] # here subscriptable access
115+ fmt = config.core.logging.format # look this, at this point I'm already using the config variable
116+ date_fmt = config[' core' ][' logging' ][' date_fmt' ] # here subscriptable access
125117
126118logging.getLogger(__name__ )
127119
@@ -136,7 +128,7 @@ logging.basicConfig(
136128for client in config.core.allowed_clients:
137129 print (client.ip)
138130 print (client.timeout)
139-
131+
140132# The config object's parts which is not a list can also be itered but, it'll give you the attribute's names
141133# So you can access the values by subscriptale access
142134for logging_section_attr_key in config.core.logging:
@@ -157,13 +149,13 @@ config = Configparser.get_config() # At this point you already have the configu
157149
158150You can also disable the action to cache the instance config
159151
152+
160153``` python
161154from pyconfigparser import Configparser
162155
163156Configparser.hold_an_instance = False
164157```
165158
166-
167159CONTRIBUTE
168160---
169161---
0 commit comments