Skip to content

Commit 2eff852

Browse files
fix(doc): Fixing documentation on README.md
1 parent 6c06954 commit 2eff852

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

README.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MAIN FEATURES
1414
* Access using OOP or subscriptable, which means that you can iterate the config object items
1515
* Runtime validation using [schema](https://github.com/keleshev/schema)
1616
* Automatic environment variables interpolation
17-
* Automatic parser selecting by config file extension
17+
* Automatic parser selecting using config file extension
1818

1919
HOW TO INSTALL
2020
===
@@ -28,10 +28,9 @@ pip install python-config-parser
2828
HOW TO USE
2929
===
3030
---
31-
By default, the config file will look for the following config files in the `.config` directory: `config.json`, `config.yaml`, `config.yml`.
32-
33-
You can also pass a config directory and or config file of your preference (assuming your current directory).
3431

32+
By default, the config file will look for any of the following config files in the `config` directory: `config.json`/`config.yaml`/`config.yml`.
33+
You can change the config directory and or config file according to your preference (assuming your current directory).
3534
```python
3635
from pyconfigparser import configparser
3736

@@ -41,10 +40,8 @@ configparser.get_config(CONFIG_SCHEMA, config_dir='your_config_dir_path', file_n
4140
Schema validation
4241
---
4342

44-
You may or may not use schema validation. If you want to use it, it will validate the whole config object before returning it.
45-
46-
If you choose not to use it, it won't validate the config object before returning it, and it may generate runtime access inconsistencies.
47-
43+
You may or not use schema validation. If you want to use it, it will validate and apply rules to the whole config object before returning it.
44+
If you choose to not use it, it won't validate the config object before returning it, and it may generate runtime access inconsistencies.
4845
How to use schema
4946

5047
```python
@@ -80,8 +77,8 @@ core:
8077
- ip: 192.168.0.11
8178
timeout: 100
8279
```
83-
A json config file would be something like:
8480
81+
A json config file would be something like:
8582
```json
8683
{
8784
"core": {
@@ -110,14 +107,14 @@ from pyconfigparser import configparser, ConfigError
110107
import logging
111108

112109
try:
113-
config = configparser.get_config(SCHEMA_CONFIG) # <- Here I'm using that SCHEMA_CONFIG we had declared, and the dir file default value is being used
110+
config = configparser.get_config(SCHEMA_CONFIG) # <- Here I'm using that SCHEMA_CONFIG we've already declared
114111
except ConfigError as e:
115112
print(e)
116113
exit()
117114

118-
# to access your config you need just:
115+
# to access your config you just need to:
119116

120-
fmt = config.core.logging.format # look this, at this point I'm already using the config variable
117+
fmt = config.core.logging.format #at this point I'm already using the config variables
121118
date_fmt = config['core']['logging']['date_fmt'] # here subscriptable access
122119

123120
logging.getLogger(__name__)
@@ -134,27 +131,25 @@ for client in config.core.allowed_clients:
134131
print(client.ip)
135132
print(client.timeout)
136133

137-
# The config object's parts which is not a list can also be itered but, it'll give you the attribute's names
138-
# So you can access the values by subscriptale access
134+
# You can also iterate objects, but instead of giving the property it'll give you the property's name
135+
# And then you can access the values by subscriptale access
139136
for logging_section_attr_key in config.core.logging:
140137
print(config.core.logging[logging_section_attr_key])
141138

142139
# Accessing the environment variable already resolved
143140
print(config.random_env_variable)
144141

145142
```
146-
Since you've already created the first Config's instance this instance will be cached inside Config class,
147-
so after this first creation you can just invoke Config.get_config()
148143

144+
Assuming you've already created the first Config's instance this instance will be cached inside Config class,
145+
so after this first creation you just need to re-invoke Config.get_config() without any argument
149146
```python
150147
from pyconfigparser import configparser
151148

152-
config = configparser.get_config() # At this point you already have the configuration properties in your config object
149+
config = configparser.get_config()
153150
```
154151

155-
You can also disable the action to cache the instance config
156-
157-
152+
You can also disable this caching behavior
158153
```python
159154
from pyconfigparser import configparser
160155

@@ -163,9 +158,9 @@ configparser.hold_an_instance = False
163158

164159
Environment Variables Interpolation
165160
---
161+
166162
If the process does not find a value already set to your env variables
167163
It will raise a ConfigError. But you can disable this behavior, and the parser will set `None` to these unresolved env vars
168-
169164
```python
170165
from pyconfigparser import configparser
171166

0 commit comments

Comments
 (0)