Skip to content

Commit b570395

Browse files
Merge pull request #19 from BrunoSilvaAndrade/develop
Develop
2 parents bd15283 + beb3dfc commit b570395

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

README.md

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
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

1110
MAIN FEATURES
1211
===
@@ -20,7 +19,7 @@ MAIN FEATURES
2019
HOW TO INSTALL
2120
===
2221
---
23-
Use pip to install it.
22+
Use `pip` to install it.
2423

2524
```shell
2625
pip install python-config-parser
@@ -29,21 +28,16 @@ pip install python-config-parser
2928
HOW 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

4842
How 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
7266
core:
7367
random_env_variable: ${RANDOM_ENV_VARIABLE}
@@ -80,7 +74,7 @@ core:
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

107101
The instance of Config Class:
108-
109102
```python
110103
from pyconfigparser import configparser, ConfigError
111104
import logging
@@ -118,9 +111,8 @@ except ConfigError as e:
118111

119112
# to access your config you need just:
120113

121-
122-
fmt = config.core.logging.format # look this, at this point I'm already using the config variable
123-
date_fmt = config['core']['logging']['date_fmt'] # here subscriptable access
114+
fmt = config.core.logging.format # look this, at this point I'm already using the config variable
115+
date_fmt = config['core']['logging']['date_fmt'] # here subscriptable access
124116

125117
logging.getLogger(__name__)
126118

@@ -135,7 +127,7 @@ logging.basicConfig(
135127
for client in config.core.allowed_clients:
136128
print(client.ip)
137129
print(client.timeout)
138-
130+
139131
# The config object's parts which is not a list can also be itered but, it'll give you the attribute's names
140132
# So you can access the values by subscriptale access
141133
for logging_section_attr_key in config.core.logging:
@@ -156,13 +148,13 @@ config = configparser.get_config() # At this point you already have the configu
156148

157149
You can also disable the action to cache the instance config
158150

151+
159152
```python
160153
from pyconfigparser import configparser
161154

162155
configparser.hold_an_instance = False
163156
```
164157

165-
166158
CONTRIBUTE
167159
---
168160
---

0 commit comments

Comments
 (0)