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)

ENCRYPTION

Using Encryption

test.ini file
[CREDENTIALS]
username = myuser
&_password = &_mypassword123
&_api_key  = &_secret_api_key_12345
python code
from iniUts import IniUts

# Initialize with encryption key
ini = IniUts('test.ini', encryption_key="my_secure_encryption_key_32_chars")

@ini.link('CREDENTIALS')
class Credentials():
    username: str
    password: str
    api_key : str

print(Credentials.username)
print(Credentials.password)
print(Credentials.api_key)

# Save encrypted values back to file
Credentials.password = "new_secure_password"
Credentials.save()
output
myuser
mypassword123
secret_api_key_12345

Note: When using encryption, the values in the INI file will be encrypted. The encryption key must be provided every time you read or write to the file.

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,envar
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"
    mode   : envar(key='MODE',default='DEV')

@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.2.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iniuts-2.0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iniuts-2.0.2.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iniuts-2.0.2.tar.gz
Algorithm Hash digest
SHA256 713eeba01c2388fe30a165d80164ceea9be31c427d2ed7b503d9329f9fb31f36
MD5 a3726e5fb7bb9e4ff0543cf38e954013
BLAKE2b-256 9eb08bd4258f95b94fb43e5fa453260b726eae4d736f89cc4ee429af02ff6d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for iniuts-2.0.2.tar.gz:

Publisher: deploy.yml on ZdekPyPi/IniUts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iniuts-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: iniuts-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iniuts-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f983da83054fe58068f9af7ceb22147e6a282eca1c88c274964c271bac68fa0f
MD5 b332c20b79185fbeac512367375bd6e6
BLAKE2b-256 c5e8a1261d23b2096348c70741430a6c923a12f32a8bd3f7afc682e77736471a

See more details on using hashes here.

Provenance

The following attestation bundles were made for iniuts-2.0.2-py3-none-any.whl:

Publisher: deploy.yml on ZdekPyPi/IniUts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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