From b374f36f34ce368fbfc2b8b56b784aa45b27ec7e Mon Sep 17 00:00:00 2001 From: kaliko Date: Wed, 5 May 2021 20:20:01 +0200 Subject: [PATCH] Use os.getenv instead of os.environ.get --- sima/lib/logger.py | 4 ++-- sima/utils/config.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sima/lib/logger.py b/sima/lib/logger.py index 50785f1..b9b8b40 100644 --- a/sima/lib/logger.py +++ b/sima/lib/logger.py @@ -26,7 +26,7 @@ Logging facility for sima. import logging import sys -from os import environ +from os import getenv DEBUG = logging.DEBUG INFO = logging.INFO @@ -56,7 +56,7 @@ def set_logger(level='info', logfile=None): logfile: file to log to """ name = 'sima' - if environ.get('TRACE', False): + if getenv('TRACE', False): user_log_level = TRACE_LEVEL_NUM else: user_log_level = getattr(logging, level.upper()) diff --git a/sima/utils/config.py b/sima/utils/config.py index a46c0c6..fd5cab6 100644 --- a/sima/utils/config.py +++ b/sima/utils/config.py @@ -30,7 +30,7 @@ import logging import sys from configparser import Error -from os import (access, makedirs, environ, stat, chmod, W_OK) +from os import (access, makedirs, getenv, stat, chmod, W_OK) from os.path import (join, isdir, isfile, dirname, exists) from stat import (S_IMODE, ST_MODE, S_IRWXO, S_IRWXG) @@ -230,10 +230,10 @@ class ConfMan: # CONFIG MANAGER CLASS http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html """ - homedir = environ.get('HOME') + homedir = getenv('HOME') - if environ.get('XDG_DATA_HOME'): - data_dir = join(environ.get('XDG_DATA_HOME'), DIRNAME) + if getenv('XDG_DATA_HOME'): + data_dir = join(getenv('XDG_DATA_HOME'), DIRNAME) elif homedir and isdir(homedir) and homedir not in ['/']: data_dir = join(homedir, '.local', 'share', DIRNAME) else: @@ -244,8 +244,8 @@ class ConfMan: # CONFIG MANAGER CLASS if self.startopt.get('conf_file'): # No need to handle conf file location pass - elif environ.get('XDG_CONFIG_HOME'): - conf_dir = join(environ.get('XDG_CONFIG_HOME'), DIRNAME) + elif getenv('XDG_CONFIG_HOME'): + conf_dir = join(getenv('XDG_CONFIG_HOME'), DIRNAME) self.conf_file = join(conf_dir, CONF_FILE) elif homedir and isdir(homedir) and homedir not in ['/']: conf_dir = join(homedir, '.config', DIRNAME) -- 2.39.5