Skip to main content

smallconfig

For Python 3.8+.

A small utility for managing script-specific settings and multiple configurations. Configuration files are stored in Appdata/Roaming as .json files. Uses only the standard library.

Quickstart

This utility contains a template class SmallConfig which handles multiple configuration files for the same script.

Create a child class of SmallConfig that implements the manager_name and default_config properties.

from smallconfig import SmallConfig as SmallConfigTemplate

class SmallConfig(SmallConfigTemplate):
    @property
    def manager_name(self):
        return 'ExampleManagerName'
    @property
    def default_config(self):
        return {
            'key': 'value',
            'is_example': True,
        }

Then create an instance of the class. Set a default configuration to clean up function calls.

config = SmallConfig('configuration.json')
config.get('key') # returns 'value'
config.set('key', 'othervalue')
config.get('key') # returns 'othervalue'
config.set_active_config('otherconfiguration.json')
config.get('key') # returns 'value'
config.get('key', 'configuration.json') # returns 'othervalue'

Other useful functions, mostly for juggling multiple configurations:

# returns a list of full file paths to configs with given manager name
config.get_configs()

# gets the config dictionary of a given config name
config.get_config('config.json')

# reloads the cache of a config directly from a file
config.reload()

# creates a new configuration file (with default settings)
config.create_config('newconfig.json')

# sets the default configuration
config.set_active_config('otherconfig.json')

Metadata

Release files for smallconfig 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smallconfig 1.0.1
File Size Uploaded Provenance Actions
smallconfig-1.0.1.tar.gz 3.8 kB Without provenance Details for smallconfig-1.0.1.tar.gz

Release files / smallconfig-1.0.1.tar.gz

Download URL smallconfig-1.0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
42128b7c1b65744493e961072f38d680193a44834d76b5203813585a80a18b3f
BLAKE2b-256 checksum
How to use checksums
470cb61cfe9145692556ab8b31294831c500f86e05e84a2836b41ad22d774a75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.5

Security for smallconfig 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page