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.3.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.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pietro_settings_manager-1.0.3.tar.gz.

File metadata

  • Download URL: pietro_settings_manager-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 aaaa8614ebdd8443e6436676a9039b47939c4bbc15bfd553bad5b85e527a0bb0
MD5 98cc2ca2e705724b2423dbb81428fce6
BLAKE2b-256 0277d1e5cdfef8bc88a4f5b4a6e0fce13f467794736df038ccfe8254a2763208

See more details on using hashes here.

Provenance

The following attestation bundles were made for pietro_settings_manager-1.0.3.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.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pietro_settings_manager-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9c00e354275f09d381e9213624f04f2b69c8ed06f2430384ac6bc21d5dc1e3a5
MD5 8fd93ca92fcd931a3b1bf661ef198453
BLAKE2b-256 ee7547d2d724f86152c45f6fcd747c755c197bf51c35656e1bd80395986e4b56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pietro_settings_manager-1.0.3-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