diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-05-16 02:58:09 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-05-16 02:58:09 +0300 |
commit | b57a7e6413a38cb4ed90877e21ae5d3a71bc368c (patch) | |
tree | fa166a5663bbe7348c39504fbbd624b910791a25 /configstore.py | |
parent | b96090540c2728dd671df137c2c146fa0f667563 (diff) | |
parent | b804a5d7e7dab93bf6056e8969a5dd4d4c52f452 (diff) |
merge master
Diffstat (limited to 'configstore.py')
-rw-r--r-- | configstore.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/configstore.py b/configstore.py deleted file mode 100644 index 36765d6..0000000 --- a/configstore.py +++ /dev/null @@ -1,55 +0,0 @@ -import os, re -from configparser import ConfigParser - -CONFIG_DIR = os.environ['HOME'] + '/.config/inverter-bot' -CONFIG_FILE = 'config.ini' - -__config__ = None - - -def _get_config_path() -> str: - return "%s/%s" % (CONFIG_DIR, CONFIG_FILE) - - -def get_config(): - global __config__ - if __config__ is not None: - return __config__['root'] - - if not os.path.exists(CONFIG_DIR): - raise IOError("%s directory not found" % CONFIG_DIR) - - if not os.path.isdir(CONFIG_DIR): - raise IOError("%s is not a directory" % CONFIG_DIR) - - config_path = _get_config_path() - if not os.path.isfile(config_path): - raise IOError("%s file not found" % config_path) - - __config__ = ConfigParser() - with open(config_path) as config_content: - __config__.read_string("[root]\n" + config_content.read()) - - return __config__['root'] - - -def get_token() -> str: - return get_config()['token'] - - -def get_shell_admin_id() -> int: - return int(get_config()['shell_admin']) - - -def get_admins() -> tuple: - config = get_config() - return tuple([int(s) for s in re.findall(r'\b\d+\b', config['admins'], flags=re.MULTILINE)]) - - -def get_isv_bin() -> str: - return get_config()['isv_bin'] - - -def use_sudo() -> bool: - config = get_config() - return 'use_sudo' in config and config['use_sudo'] == '1'
\ No newline at end of file |