""" Functions for handling the program's configuration file """ from configparser import ConfigParser import os CONFIG_FILE = os.path.expanduser("~/.config/joc/config.ini") def read_config_file(): """ Read config file and return ConfigParser instance """ parser = ConfigParser(inline_comment_prefixes="#") parser.read(os.path.expanduser(CONFIG_FILE)) return parser def write_config_file(parser:ConfigParser): """ Write ConfigParser contents back to config file """ with open(os.path.expanduser(CONFIG_FILE), "w") as conf: parser.write(conf)