From: kaliko Date: Wed, 5 May 2021 18:20:01 +0000 (+0200) Subject: Use os.getenv instead of os.environ.get X-Git-Tag: 0.18.0~58 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=b374f36f34ce368fbfc2b8b56b784aa45b27ec7e;p=mpd-sima.git Use os.getenv instead of os.environ.get --- 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)