import json import munch import os import configparser path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..\\')) parser = configparser.ConfigParser( interpolation=configparser.ExtendedInterpolation()) parser.read(os.path.join(path, 'config.ini')) with open(os.path.join(path, 'keycodes.json')) as k: keycodes = munch.munchify(json.load(k)) config = parser.__dict__['_sections'] for key, value in config['local'].items(): config['local'][key] = os.path.expandvars(value) loaded = munch.munchify(dict(config=config, keycodes=keycodes))