Skip to main content

Ini file manipulator

Project description

Ini File Uts

Installation

pip install iniUts

Usage

read

test.ini file
[Person]
name    = myname
age     = 31
amount  = 20.3
friends = friend1,friend2,friend3
dob     = 1991-12-23
python code
from iniUts import IniUts

ini = IniUts('test.ini')
data = ini.read('Person','name')

print(result)
output
"myname"

write

test.ini file
[PERSON]
name    = myname
python code
from iniUts import IniUts

ini = IniUts('test.ini')
ini.write('PERSON','last_name','mylastname')
test.ini file
[PERSON]
name      = myname
last_name = mylastname

getKeys

test.ini file
[PERSON]
name      = myname
last_name = mylastname
python code
from iniUts import IniUts

ini = IniUts('test.ini')
keys = ini.getKeys("PERSON")
print(keys)
output
['name','last_name']

Section2Dict

test.ini file
[PERSON]
name    = myname
age     = 31
amount  = 20.3
friends = friend1,friend2,friend3
dob     = 1991-12-23
python code
from iniUts import IniUts

ini = IniUts('test.ini')
ini.Section2Dict('PERSON')
print(Person)
output
{
    "name"    = "myname"
    "age"     = "31"
    "amount"  = "20.3"
    "friends" = "friend1,friend2,friend3"
    "dob"     = "1991-12-23"
}

section2DataClass

test.ini file
[PERSON]
name    = myname
age     = 31
amount  = 20.3
friends = friend1,friend2,friend3
dob     = 1991-12-23
python code
from iniUts import IniUts
from datetime import datetime
from dataclasses import dataclass

@dataclass
class Person():
    name   : str
    age    : int
    amount : float
    friends: tuple = ','
    dob    : datetime = "%Y-%m-%d"

ini = IniUts('test.ini')
ini.Section2Dict("section2DataClass")

print(Person.name)
print(Person.age)
print(Person.amount)
print(Person.friends)
print(Person.dob)
output
myname
31
20.3
("friend1","friend2","friend3")
datetime.datetime(1991, 12, 2, 0, 0)

Change Log

1.0.0 (2023-04-26)

  • First Release

1.0.1 (2023-04-26)

  • Bug Fixed

1.0.2 (2023-04-26)

  • Upercase Bug Fixed

1.0.3 (2023-04-26)

  • Upercase Write Bug Fixed

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

iniUts-1.0.3.tar.gz (2.1 MB view hashes)

Uploaded Source

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