optimal solution to read and save a config file.
Project description
C2D
optimal solution to read and save a config file.
Install
pip install C2D
Usage
- Import C2D
from C2D import C2D
- Create object
config=C2D.C2D()
- Create config.ini
from C2D import C2D
key={'section': {'name': 'c2d',
'version': '1.0'
},
'install': {'date': '23/12/2019'}
}
# Create C2D Object
config=C2D.C2D(keys=key)
#This will Save config.ini file
config.Save()
if you want to give custom file NAME
config=C2D.C2D(file='Test.ini',keys=key)
- Read Config File
from C2D import C2D
config=C2D.C2D()
keys_values=config.Read()
print(keys_values)
Output
{'section': {'name': 'c2d', 'version': '1.0'}, 'install': {'date': '23/12/2019'}}
To Read a Custom file
config=C2D.C2D(file='Test.ini')
- Read All Sections
from C2D import C2D
config=C2D.C2D()
config.Read()
print(config.Sections())
Output
['section', 'install']
- Read Values By Section Name
from C2D import C2D
config=C2D.C2D()
config.Read()
print(config.Values('install'))
Output
{'date': '23/12/2019'}
Help
>>> help(C2D)
Help on module C2D.C2D in C2D:
NAME
C2D.C2D
CLASSES
builtins.object
C2D
class C2D(builtins.object)
| C2D(file='config.ini', keys=None, sep='=')
|
| C2D is an class for creating and reading config.ini files.
|
| Create Object:
| -------------
| obj=C2D(file='config.ini',keys=None,sep='=')
|
| Parameter:
| ---------
| file: optional,any File name ,default file name is config.ini
| sep : optional,separator,defualt separator is =
| key : optional,an Dictionary object
|
| key={
| 'section': {
| 'name': 'c2d',
| 'version': '1.0'
| },
| 'install': {
| 'date': '23/12/2019'
| }
| }
| Methods:
| -------
| obj.Save() : save config file
| obj.Read() : read config file and return config dict object.
| obj.Sections(): list of section in config.ini
| obj.Values() : all avialable paramters and Values
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
C2D-0.0.1.tar.gz
(2.9 kB
view details)
Built Distribution
C2D-0.0.1-py3-none-any.whl
(4.1 kB
view details)
File details
Details for the file C2D-0.0.1.tar.gz
.
File metadata
- Download URL: C2D-0.0.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6a3b42c0f17b02a808ce60238a9eec5cabfc75f47852a2b7e7a3e5c252a324f |
|
MD5 | 93ee071acbea7569a6b93fe2f2b6e2b0 |
|
BLAKE2b-256 | ca8546923f358b1aec2f79d43e500e8ee2b183588fdbec11b533a89ff6f96368 |
File details
Details for the file C2D-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: C2D-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f85522cb46b0fbe789fb83f90e304934ac4a2e256493285dcab35fc4eee8e9a |
|
MD5 | 8153fed6fa3d46a7d2c07b1b3c9aa141 |
|
BLAKE2b-256 | da6286243a04e8dbd9daebc87dafc99d5e87f9d46983fe00fde732a00900b581 |