Skip to main content

A basic configuration loader intended for my own scripts, but might be useful for other people.

Project description

basic-config-loader

Load a JSON configuration from a file, or from multiple folders on the filesystem.

Getting Started

Prerequisites

This project has no dependencies. Yay!

Installing

pip install basic-config-loader

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Usage

import configLoader as cl
...
CONFIG = cl.loadConfig(...)
...

:param path: the path to look for the file. It is recommended to provide the result of os.path.join() rather than a manually typed path because a certain OS which must not be named has different path conventions than everyone else.

:param default: the configuration to return if loading from the filesystem fails.

:param fromHome: if True, look from the current user's home directory. If False, look from the root directory.

:param topSearchPath: if None, only look in the specified path for the file. Otherwise, a path should be provided. 'HOME' can be filled in as a shortcut for os.environ['HOME']. The exact behavior depends on fullSearchAlways.

:param fullSearchAlways: if False, and the directory specified in path is empty, move up one folder, up to topSearchPath, until a config file is found, and use the first file found. If no file is found, use the default config. If True, start with the default configuration and apply any changes from topSearchPath to path in order.

:return: the configuration if loading was successful, or the default configuration if loading failed.

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

basic-config-loader-0.2.0.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

basic_config_loader-0.2.0-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

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