def unset_path(var_name): var_name = var_name.lower() config = load_config() try: path = config['paths'].pop(var_name) save_config(config) print '"{}" has been unset'.format(var_name) except KeyError: print 'Error: path variable "{}" does not exist'.format(var_name)
def set_path(var_name, path): var_name = var_name.lower() if os.path.isdir(path): config = load_config() path = os.path.abspath(path) config['paths'][var_name] = path save_config(config) print '"{}" saved as "{}"'.format(path, var_name) else: print '"{}" does not seem to be a directory'.format(path)
"help": "Data to be used by the application internally.", "data": { "timezone": { "default": "UTC", "help": "Timezone of where you live." }, "hours": { "default": [ "08:10 08:50", "09:00 09:40", "09:50 10:30", "10:40 11:20", "11:30 12:10", "12:55 13:35", "13:45 14:25", "14:35 15:15", "00:00 23:59" ], "help": "Starting and finishing times of classes." } } } } config_manager.create_folders(FOLDERS) config_manager.create_files(FILES) config = config_manager.load_config(CONFIG_PATH) res = config_manager.check_config(config, CONFIG_TEMPLATE) config_manager.save_config(CONFIG_PATH, config) if res: print(f"Please fill in null values in {CONFIG_PATH}") sys.exit(1) tz = pytz.timezone(config["settings"]['timezone'])