From 636d2d390f7636294d573a8d78ed2e62053b9f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Mon, 11 Feb 2019 19:26:44 +0100 Subject: [PATCH] core.settings: Pylint/style fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some pylint fixes and removal of not necessary import. Signed-off-by: Lukáš Doktor --- avocado/core/settings.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/avocado/core/settings.py b/avocado/core/settings.py index c35a336279..e1b3ed8daf 100644 --- a/avocado/core/settings.py +++ b/avocado/core/settings.py @@ -17,7 +17,6 @@ """ import ast import os -import sys import glob try: @@ -116,27 +115,25 @@ def convert_value_type(value, value_type): value_type = str # if length of string is zero then return None - if len(sval) == 0: + if not sval: if value_type == str: return "" - elif value_type == os.path.expanduser: + if value_type == os.path.expanduser: return "" - elif value_type == bool: + if value_type == bool: return False - elif value_type == int: + if value_type == int: return 0 - elif value_type == float: + if value_type == float: return 0.0 - elif value_type == list: + if value_type == list: return [] - else: - return None + return None if value_type == bool: if sval.lower() == "false": return False - else: - return True + return True if value_type == list: return ast.literal_eval(sval) @@ -163,12 +160,10 @@ def __init__(self, config_path=None): self.config_paths = [] self.all_config_paths = [] _source_tree_root = os.path.dirname(os.path.dirname(os.path.dirname( - sys.modules[__name__].__file__))) + __file__))) # In case "examples" file exists in root, we are running from tree - if os.path.exists(os.path.join(_source_tree_root, 'examples')): - self.intree = True - else: - self.intree = False + self.intree = bool(os.path.exists(os.path.join(_source_tree_root, + 'examples'))) if config_path is None: if 'VIRTUAL_ENV' in os.environ: cfg_dir = os.path.join(os.environ['VIRTUAL_ENV'], 'etc')