import json from collections import UserDict import os import sys from . import data class SettingsLoader(UserDict): def __init__(self: object, file: str) -> None: self.data = {} self.load_settings_file(file) def load_settings_file(self: object, file: str) -> None: ext = os.path.splitext(file)[1] with data.data_open('conf', file) as fd: if ext == '.json': self.data.update(json.load(fd)) else: raise ValueError("Cannot open this type of settings file") class SettingsReadOnly(SettingsLoader): pass class SettingsMutable(SettingsLoader): pass class SettingsWritable(SettingsMutable): pass init = SettingsWritable('init.json')