Skip to main content

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pietro_settings_manager-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 9fae65f92b1c587ae6f64450c3bd46881fe6305db9d1b75bbb3f758010f01e57
MD5 99df00a3b4e998c6a5246e600ffe22eb
BLAKE2b-256 b03fe14b4efdb347cc7261dad26ea9a17cd1f928d18dd075a85de1d073b4f4cf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pietro_settings_manager-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1a89a83a2ca7f902b6a199ade467597869e28c3cf194ef285bf5bbb35521868
MD5 176abd55ca2cf3457b9de8baee1fd5bd
BLAKE2b-256 4d1650bd269f9c8b7bc1ce0d81c41befabb305becb504406c5deb61ca842b713

See more details on using hashes here.

Provenance

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