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 (it's gone, but will be back soon...) with more features.
Installation
- using pip
- from pypi
pip install iniparser2
pip install iniparser2 --upgrade
- from github repository
pip install git+https://github.com/HugeBrain16/iniparser2.git
- from source
pip install .
- from pypi
- from source
python setup.py install
python setup.py install --user
Examples
reading ini basic example
import iniparser2
string = """
[stuff] # stuff that i stole from your house
microwave = 2
bagle = 8
money = $2100
person = 1
something_else = 69
"""
parser = iniparser2.INI()
parser.read(string)
print(parser)
read-write example
something.ini
[stuff] # stuff that i stole from your house
microwave = 2
bagle = 8
money = $2100
person = 1
something_else = 69
le_main.py
import iniparser2
parser = iniparser2.INI(convert_property=True) # this `convert_property` does something like conversion...
parser.read_file('something.ini')
print(parser) # old stuff
# let's steal some more stuff
parser.set('person', parser.get('person', section='stuff') + 1, section='stuff') # kidnap one more person from your house
parser.set('bagle', parser.get('bagle', section='stuff') + 3, section='stuff') # and some bagles...
parser.set('dog', 1, section='stuff') # ohh, there is a dog, imma take that
parser.write('something.ini') # update file
print(parser) # let's see what i got here..., ohh wait!-
parser.remove_property('dog', section='stuff') # nevermind
parser.write('something.ini') # alright let's get outta here
# overread parser items
parser.read_file('something.ini')
print(parser) # new stuff
weird binary file stuff
import iniparser2
string = """
[robot-1]
text = beep boop?
[robot-2]
text = boop? beep beep sus
[robot-3]
text = amogus
"""
parser = iniparser2.INI()
parser.write_string_bin('something.ini', string)
parser.read_binfile('something.ini')
print(parser)
Exceptions
exceptions because why not
- base exception
ParsingError
SectionError
PropertyError
- something else
DuplicateError
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
iniparser2-2.0.0.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for iniparser2-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1671c7e946ded801830e964e06182ca972ba6aa8cb358aef5f5c400afb2a5617 |
|
MD5 | 28f5bd20efaf57bb8ee03da7f34a8fca |
|
BLAKE2b-256 | 0c5fd3610778ecedb0494281175c4c2e5d3c69a68401824e8eb40727ff5347fb |