diff --git a/src/sessionmanager/jconfig_patched.py b/src/sessionmanager/jconfig_patched.py new file mode 100644 index 0000000..1d80693 --- /dev/null +++ b/src/sessionmanager/jconfig_patched.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +""" Modified Jconfig base class """ +import logging +import json +from codecs import open +from jconfig import jconfig + +log = logging.getLogger('jconfig_patched') + +class Config(jconfig.Config): + + log.info("Instantiated patched jconfig instance") + + def load(self, filename, **kwargs): + try: + with open(filename, 'r', encoding="utf-8") as f: + settings = json.load(f) + except (IOError, ValueError): + settings = {} + + settings.setdefault(self.section_name, {}) + + return settings + + def save(self): + with open(self._filename, 'w', encoding="utf-8") as f: + json.dump(self._settings, f, indent=2, sort_keys=True) diff --git a/src/sessionmanager/vk_api_patched.py b/src/sessionmanager/vk_api_patched.py index f5da838..b6ae4a0 100644 --- a/src/sessionmanager/vk_api_patched.py +++ b/src/sessionmanager/vk_api_patched.py @@ -5,7 +5,7 @@ import logging import vk_api import threading import requests -import jconfig +import jconfig_patched as jconfig from vk_api.enums import VkUserPermissions from vk_api.exceptions import *