An INI parser or config parser
Project description
iniparser2
iniparser2 is An INI parser or a Config parser.
this package is the improved version of iniparser with more features.
Quick Start
Installation
to install the package see the following step below
from source: python setup.py install
Examples
These examples below is for getting the value from the properties
basic example
test.ini
:
name=Mike Hawk
test.py
:
from iniparser2 import INI
x = INI('test.ini')
data = x.get()
print(data)
Output:
{'name': 'Mike Hawk'}
using with
keyword
test.ini
:
name=Mike Hawk
test.py
:
from iniparser2 import INI
with INI('test.ini') as i:
print(i.get())
Output:
{'name': 'Mike Hawk'}
OR With temp
method
test.py
:
from iniparser2 import INI_TEMP
x = INI_TEMP()
data = x.parse(
"""
name=Mike Hawk
""")
print(data)
Output:
{'name': 'Mike Hawk'}
OR With section
test.ini
:
[id]
name=Mike Hawk
age=-69
test.py
:
from iniparser2 import INI
x = INI('test.ini','id') # 'id' is the section name
data = x.get()
print(data)
Output:
{'name': 'Mike Hawk', 'age': '-69'}
pass_section argument
test.ini
:
brief=someone's identity
[id]
name=Mike Hawk
age=-69
test.py
:
from iniparser2 import INI
x = INI('test.ini',pass_section=True) # or you just don't have to put the section name, it will override the `pass_section` argument
data = x.get()
print(data)
Output:
{'brief': "someone's identity", 'id': {'name': 'Mike Hawk', 'age': '-69'}}
These example below is for properties stuff
basic example
the test.ini
file is empty
test.py
:
from iniparser2 import INI
x = INI('test.ini')
x.set('name','Mike Hawk')
and the test.ini
file would be like this
name=Mike Hawk
it would update the value of the property if there's an existing property inside the file
to unset property
test.py
:
from iniparser2 import INI
x = INI('test.ini')
x.unset('name')
and the property would be gone!
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
Built Distribution
Hashes for iniparser2-1.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4376d7a730883e3f86cbbde51fb9a29e47121f188eb2764d8880f7db14d1ea45 |
|
MD5 | ad2780d3c9228b569cd6971404d60575 |
|
BLAKE2b-256 | f52c16683e11d0d142f84e2cb415ca237eded2862fe383519dbe9d2829b659bf |