Simple use ini files
Project description
This is the simplest way to interact with a single ini file to store settings.
Attention! It is delivered together with logging to a file. You need to try to understand.
Use:
from simpleini import SETTINGS, logging
parsed_data = SETTINGS(<names_settings>, <required_settings>)
# names_settings - A string with the names of the settings stored in the file. If there is no file, it will be created and the program will be completed.
# required_settings - comma-separated list of required variables. 'all' - to check all variables
```python
#### Example ini reader (simple mode):
```python
# Read from [DEFAULT] section
parsed_data = SETTINGS('settings1, settings2, settings3', 'all')
settings1 = parsed_data.settings1
settings2 = parsed_data.settings2
settings3 = parsed_data.settings3
```python
#### Examle ini readred
```python
parsed_data = SETTINGS()
settings1 = parsed_data.section_name.settings1
settings2 = parsed_data.section_name.settings2
settings3 = parsed_data.section_name_2.settings1
```python
#### Example with required fields
```python
settings = SETTINGS(required_fields='NEW_DEFAULT.path_default')
```python
#### Example set
```python
settings.set('test.one', 123)
```python
#### Example remove section
```python
settings.remove('section_name')
```python
#### Example remove option
```python
settings.remove('section_name.option_name')
```python
#### Example logging:
```python
logging('message for log') # it will write a file to the project folder log.txt and it will add incoming information to it
```python
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
simpleini-0.1.8.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for simpleini-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a42a32cbe646e27b8d9e6a2749e9b8c1f0e983b34a0fcfc78c7075e3e339a585 |
|
MD5 | a6adec5a40cbee9ba8290c41d22d70a8 |
|
BLAKE2b-256 | 87027de7ddc23bd8895844477d46f2724b6a3f2222ed0cb4243ab550abf00464 |