Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 2.23 KB

README.md

File metadata and controls

61 lines (45 loc) · 2.23 KB

pypi python license docs patreon paypal follow

cfgsaver

project logo

Python library to save and fetch configuration data in a standard/conventional path and format.

Installation

pip install cfgsaver

Usage

Import the cfgsaver module to save/read configuration values in your source files:

from cfgsaver import cfgsaver

def save_config():
	# saves configuration data to ~/.config/<your_package>/cfg.json
	# unless cfgpath parameter is overridden:
	config = {
	'name': 'Prahlad', 
	'language': 'Python', 
	'framework': 'Flask'
	}
	cfgsaver.save('<your_package>', config)

def get_config():
	# gets configuration data from ~/.config/<your_package>/cfg.json 
	# unless cfgpath parameter is overridden:
	config = cfgsaver.get("<your_package>") #returns None if config file doesn't exist
	
def prompt_user():
	# prompts user for config keys and saves resulting values as per save_config()
	config = {
	'name': '', 
	'language': '', 
	'framework': ''
	}
	config = cfgsaver.get_from_cmd("<your_package>", config.keys())

For information on shipping default configuration data packaged with your app using setup.py, read detailed docs.

Documentation

Detailed docs are available at https://cfgsaver.readthedocs.io/en/latest/.

Attribution

Icons made by Smashicons from www.flaticon.com is licensed by CC 3.0 BY