29 lines
729 B
Python
29 lines
729 B
Python
import json
|
|
from collections import UserDict
|
|
import os
|
|
import sys
|
|
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.open('conf', file) as fd:
|
|
if ext == '.json':
|
|
self.data.extend(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')
|