Skip to main content

Ini file manipulator

Project description

Ini Uts

Installation

pip install iniUts

GitHub

https://github.com/ZdekPyPi/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"
}

link

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

ini = IniUts('test.ini')

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

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)

ENVIORNMENT CHANGING

Link

prd.ini file
[PERSON] 
name    = myName # Will be changed in DEV
age     = 31
amount  = 20.3
friends = friend1,friend2,friend3
dob     = 1991-12-23

[CONFIG]
ip    = <some_ip>
path  = <some_path> # Will be changed in DEV
dev.ini file
[PERSON] #change only PERSON name
name    = myOtherName

[CONFIG] #change only CONFIG path
path    = <another_path>
python code
from iniUts import IniUts
from datetime import datetime
from dataclasses import dataclass

ini = IniUts('prd.ini','dev.ini',in_prd=True) #CHANGE S WILL BE MADE IF IN DEVELOPMENT MODE

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

@ini.link('CONFIG')
class Config():
    ip   : str
    path : str


print(Person.name)
print(Person.age)
print(Config.ip)
print(Config.path)
output
#==================== IN PRD
myName
31
<some_ip>
<some_path>
#==================== IN DEV
myOtherName
16
<some_ip>
<some_path>

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

1.0.4 (2023-04-28)

  • Update Class bug fixed

1.0.6 (2023-04-28)

  • empty_as_null

1.0.7 (2023-04-28)

  • changing enviornment

1.3.0 (2025-12-01)

  • encription and decription

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-2.0.1.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file iniuts-2.0.1.tar.gz.

File metadata

  • Download URL: iniuts-2.0.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for iniuts-2.0.1.tar.gz
Algorithm Hash digest
SHA256 2cee4d91f6c045ce4838a1c797438c7ee5441a9c12e17f7192e76929b957295e
MD5 72318633e234a33877994fbaefbfcaed
BLAKE2b-256 3e24acbf152dc15549e55ff1725c8034dda6a4873bec68d6f232662ad0230cff

See more details on using hashes here.

Supported by

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