Skip to main content

A Python settings manager package that allows you to make settings handling easy.

Project description

CD

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 configparser module 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

pietro_settings_manager-1.0.4.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

pietro_settings_manager-1.0.4-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

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

Hashes for pietro_settings_manager-1.0.4.tar.gz
Algorithm Hash digest
SHA256 8ccb527a69b88c0ada08a3a39db378d52892b5e3b7af350d3b0b34caeec6f96a
MD5 e3fc19e787ed4e4ce1f24b1ac05ed8de
BLAKE2b-256 488c52efd524d0501ef2171df1eb2b45cb2fe81bd067be8f0457703f94b258d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pietro_settings_manager-1.0.4.tar.gz:

Publisher: publish.yml on P1etrodev/settings-manager

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

File details

Details for the file pietro_settings_manager-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pietro_settings_manager-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fb273e81b1b4c42e51c0a6a721788803f671aaad2efb6f9be702249064c4bcfa
MD5 f9af98e5a649a6ff954553bbe882c327
BLAKE2b-256 2f49ffe76e21880ef910f39188917953be9218b41cad36490c480407accfde81

See more details on using hashes here.

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

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