Skip to main content

An extension of configparser

Project description

Build-Settings

Build-Settings is an extension of the configparser library, designed to enhance its functionality by providing the ability to add, update, and refresh settings in real-time. It offers provisions for creating backups and securely storing credentials using environment variables.

Features

  • Real-time Settings Management: Build-Settings empowers users to dynamically add, update, and refresh settings without requiring manual intervention.

  • Backup Functionality: The library includes robust backup capabilities, ensuring that users can maintain the integrity of their configuration files and easily revert changes if necessary.

  • Secure Credential Storage: Build-Settings facilitates secure credential storage by offering support for environment variables, allowing sensitive information to be stored separately from configuration files.

Usage

Import and setup

import os
from settings import BuildSettings

setpath = os.path.abspath(os.path.join(os.path.dirname(__file__)))
settings = BuildSettings(setpath + '/tests_output.ini', setpath + '/tests.ini')

Add a setting

settings.add('test_setting_not_default', 'True')

Change the value of a setting

settings.set('string_setting', 'not_default')

Save settings

settings.save()

Reload settings

settings.load()

Upgrade settings merging new values from the defaults (this also happens on init)

settings.upgrade()

Clean extra settings from the running configuration that aren't present in defaults

settings.clean()

Settings within the [secure] section will be loaded directly into the environment and can only be retrieved using settings.get_secure("value") method

[settings]
string_setting = default_string
numeric_setting = 42
list_setting = [1, 2, 3]
tuple_setting = (4, 5, 6)
dict_setting = {'key1': 'value1', 'key2': [7, 8, 9], 'key3': (10, 11, 12)}
string_setting_2 = another_default_string
numeric_setting_2 = 100
list_setting_2 = [4, 5, 6]
tuple_setting_2 = (7, 8, 9)
dict_setting_2 = {'key3': 'value3', 'key4': {'inner_key1': 'inner_value1', 'inner_key2': [13, 14, 15]}}
nested_string_setting_3 = nested_default_string
nested_numeric_setting_3 = 999
nested_list_setting_3 = [7, 8, 9]
nested_tuple_setting_3 = (10, 11, 12)
nested_dict_setting_3 = {'key5': 'value5', 'key6': {'inner_key3': 'inner_value3', 'inner_key4': [16, 17, 18]}}
[secure]
password = '!@#$^&*'
private_key = 'age62gD5j6&gjwoifc?f385gwovS'
print('secure_value', settings.get_secure('private_key'))

Add or update a secure value (immediately loaded into the environment and saved to file)

settings.set_secure('key', 'value')

Backups are made when the settings file is changed, backups are not mode when the settings are default, empty, or are identical to the most recent backup.

Backups are restored when a backup is present and the settings file is missing, empty, or has reverted to defaults.

Installation

You can install Build-Settings via pip:

pip install build-settings

Getting Started

For detailed instructions on how to use Build-Settings, please refer to the documentation.

Support and Contributions

If you encounter any issues or have suggestions for improvement, please feel free to open an issue on GitHub. Contributions are also welcome, and pull requests will be reviewed promptly.

License

Build-Settings is licensed under the MIT License. See the LICENSE file for more information.

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

build-settings-0.1.7.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

build_settings-0.1.7-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file build-settings-0.1.7.tar.gz.

File metadata

  • Download URL: build-settings-0.1.7.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for build-settings-0.1.7.tar.gz
Algorithm Hash digest
SHA256 cac8b68f09cf1d12b5b616b857837a0d747cc4e1f8a09b5d4c08add58fb990de
MD5 f821dc906bac2753c6c558f76ebdc20e
BLAKE2b-256 4f19cbdcb64bb1777932f8b7227e7aac7b6fa312652a5e7406a53431dbc8fdb4

See more details on using hashes here.

File details

Details for the file build_settings-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for build_settings-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4c9b39e35e478f22481dfe5dcbde71b40abf4f215e1fae118f9f6032f6bad6c8
MD5 ef0818314ddd22305e88d9056cb5b99c
BLAKE2b-256 d1f3b3fecbe7059575e125d0e770184a885b324286b186549a6713f9da0a79cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page