Skip to main content

Module to save and fetch configuration data in a standard path and format.

Project description

pypi python implementation

license last-commit

donate follow


project logo

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


pip install cfgsaver


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'
	}'<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

In case you want to ship some default configuration data packaged with your app, then read the below instructions carefully:

Ensure to include the path to your cfg.json in as follows (you'll have to copy this file from ~/.config/<your_package> to your source directory for packaging purpose):

include <your_package>/cfg.json

Override the PostInstall class in your like this in order to save your config file to the user's machine after installation:

from setuptools import setup, find_packages
from setuptools.command.install import install
import shutil

class PostInstallCommand(install):
	"""Post-installation for installation mode."""
	def run(self):
		fpath = os.path.join(self.install_lib, your_package)
		fpath = os.path.join(fpath, "cfg.json")
		tpath = os.path.join(os.path.expanduser("~"), ".config/<your_package>/cfg.json")
		if not os.path.isdir(tpath):
		shutil.move(fpath, tpath)

s = setup(
	name = "your_package",
		'install': PostInstallCommand,


Icons made by Smashicons from is licensed by CC 3.0 BY

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cfgsaver, version 1.0.4
Filename, size File type Python version Upload date Hashes
Filename, size cfgsaver-1.0.4.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page