Skip to main content

An INI parser or config parser

Project description

iniparser2

Build Status

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iniparser2-1.6.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

iniparser2-1.6.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file iniparser2-1.6.0.tar.gz.

File metadata

  • Download URL: iniparser2-1.6.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for iniparser2-1.6.0.tar.gz
Algorithm Hash digest
SHA256 6ff82d80c13a73a869b153d927732faf879d95efad3f73adb13f68d7f287915a
MD5 8d0c2ec290cb4ec6d7299de50d11900e
BLAKE2b-256 078660e24894615fba1bfcec03a609a75a2ee80b9ccbf969d7dd07a2a039c937

See more details on using hashes here.

File details

Details for the file iniparser2-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: iniparser2-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for iniparser2-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 394afae34b809deb013d556cf839277fe71acba6123aa9e79fe9234ff445b94c
MD5 180aeb57462c67cfa835a8d28b9721f5
BLAKE2b-256 f2c5da71ff9d2c3de53d028748b0df60262454c2da4ce0f0d7a682c4d52e7eff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page