A Python settings manager package that allows you to make settings handling easy.
Project description
SettingsManager
A simple Python class for managing configuration settings using an INI file. The class provides methods to load, save, get, and set configuration values, with support for default settings and type conversion.
Features
- Load and save settings from/to an INI file.
- Apply default settings if the configuration file does not exist.
- Get configuration values with optional type conversion (
bool,int,float). - Set configuration values, ensuring the section exists before setting the key-value pair.
- Uses Python's
configparsermodule for parsing INI files.
Usage
# Define default configuration values
default_config = {
"general": {
"theme": "light", # Default theme
"language": "en", # Default language
"notifications_enabled": True # Enable notifications by default
},
"user": {
"username": "default_user", # Default username
"email": "user@example.com" # Default email address
}
}
# Create an instance of SettingsManager with a specific config file and default values
settings_manager = SettingsManager(file_name="my_config.ini", defaults=default_config)
# Load configuration from the file (if it exists) or apply the default values
settings_manager.load()
# Retrieve configuration values using the 'get' method
theme = settings_manager.get("general", "theme") # Get the theme value
language = settings_manager.get("general", "language") # Get the language value
notifications_enabled = settings_manager.get("general", "notifications_enabled", "bool") # Get notifications status as a boolean
# Print the retrieved configuration values
print(f"Theme: {theme}")
print(f"Language: {language}")
print(f"Notifications enabled: {notifications_enabled}")
# Change some configuration values
settings_manager.set("general", "theme", "dark") # Change theme to dark
settings_manager.set("user", "username", "new_user") # Change username
# Save the changes to the configuration file
settings_manager.save()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pietro_settings_manager-1.0.4.tar.gz.
File metadata
- Download URL: pietro_settings_manager-1.0.4.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ccb527a69b88c0ada08a3a39db378d52892b5e3b7af350d3b0b34caeec6f96a
|
|
| MD5 |
e3fc19e787ed4e4ce1f24b1ac05ed8de
|
|
| BLAKE2b-256 |
488c52efd524d0501ef2171df1eb2b45cb2fe81bd067be8f0457703f94b258d5
|
Provenance
The following attestation bundles were made for pietro_settings_manager-1.0.4.tar.gz:
Publisher:
publish.yml on P1etrodev/settings-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pietro_settings_manager-1.0.4.tar.gz -
Subject digest:
8ccb527a69b88c0ada08a3a39db378d52892b5e3b7af350d3b0b34caeec6f96a - Sigstore transparency entry: 175311385
- Sigstore integration time:
-
Permalink:
P1etrodev/settings-manager@91736a5db540630c7e3771ca41795aa7fc8930ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/P1etrodev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91736a5db540630c7e3771ca41795aa7fc8930ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file pietro_settings_manager-1.0.4-py3-none-any.whl.
File metadata
- Download URL: pietro_settings_manager-1.0.4-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb273e81b1b4c42e51c0a6a721788803f671aaad2efb6f9be702249064c4bcfa
|
|
| MD5 |
f9af98e5a649a6ff954553bbe882c327
|
|
| BLAKE2b-256 |
2f49ffe76e21880ef910f39188917953be9218b41cad36490c480407accfde81
|
Provenance
The following attestation bundles were made for pietro_settings_manager-1.0.4-py3-none-any.whl:
Publisher:
publish.yml on P1etrodev/settings-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pietro_settings_manager-1.0.4-py3-none-any.whl -
Subject digest:
fb273e81b1b4c42e51c0a6a721788803f671aaad2efb6f9be702249064c4bcfa - Sigstore transparency entry: 175311387
- Sigstore integration time:
-
Permalink:
P1etrodev/settings-manager@91736a5db540630c7e3771ca41795aa7fc8930ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/P1etrodev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91736a5db540630c7e3771ca41795aa7fc8930ae -
Trigger Event:
push
-
Statement type: