From 014d11c780c74fe35dce7cccd0becd7c3f3c744e Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 8 Jun 2015 14:36:07 -0300 Subject: [PATCH] API review: use relative imports in avocado.utils modules It was mentioned that we should think of avocado.utils as a subproject that happens to live in the same source tree. So, it should not make use of any avocado module. If that's the case, maybe we don't want to keep referencing 'avocado.utils' in the utils module themselves. This is in accordance with PEP-0328[1] [1] - https://www.python.org/dev/peps/pep-0328/ Signed-off-by: Cleber Rosa --- avocado/utils/build.py | 2 +- avocado/utils/download.py | 2 +- avocado/utils/gdb.py | 4 ++-- avocado/utils/genio.py | 2 +- avocado/utils/kernel_build.py | 2 +- avocado/utils/memory.py | 2 +- avocado/utils/path.py | 2 +- avocado/utils/process.py | 3 ++- avocado/utils/remote.py | 2 +- avocado/utils/script.py | 2 +- avocado/utils/software_manager.py | 8 ++++---- avocado/utils/virt.py | 2 +- 12 files changed, 17 insertions(+), 16 deletions(-) diff --git a/avocado/utils/build.py b/avocado/utils/build.py index 2be48098..c8e30727 100644 --- a/avocado/utils/build.py +++ b/avocado/utils/build.py @@ -14,7 +14,7 @@ import os -import process +from . import process def make(path, make='make', env=None, extra_args='', ignore_status=False, allow_output_check='none'): diff --git a/avocado/utils/download.py b/avocado/utils/download.py index a85474a7..cc62955d 100644 --- a/avocado/utils/download.py +++ b/avocado/utils/download.py @@ -23,7 +23,7 @@ import socket import shutil import urllib2 -from avocado.utils import aurl +from . import aurl log = logging.getLogger('avocado.test') diff --git a/avocado/utils/gdb.py b/avocado/utils/gdb.py index 65501847..bdde9778 100644 --- a/avocado/utils/gdb.py +++ b/avocado/utils/gdb.py @@ -30,8 +30,8 @@ try: except ImportError: import subprocess -from avocado.utils import network -from avocado.utils.external import gdbmi_parser +from . import network +from .external import gdbmi_parser GDB_PROMPT = '(gdb)' GDB_EXIT = '^exit' diff --git a/avocado/utils/genio.py b/avocado/utils/genio.py index 21a95cf2..0e88863c 100644 --- a/avocado/utils/genio.py +++ b/avocado/utils/genio.py @@ -20,7 +20,7 @@ import logging import os import time -from avocado.utils import path as utils_path +from . import path as utils_path log = logging.getLogger('avocado.test') diff --git a/avocado/utils/kernel_build.py b/avocado/utils/kernel_build.py index e657072e..2fbe29ee 100755 --- a/avocado/utils/kernel_build.py +++ b/avocado/utils/kernel_build.py @@ -18,7 +18,7 @@ import os import logging import shutil -from avocado.utils import download, archive, build +from . import download, archive, build log = logging.getLogger('avocado.test') diff --git a/avocado/utils/memory.py b/avocado/utils/memory.py index fdeed623..5515cd78 100644 --- a/avocado/utils/memory.py +++ b/avocado/utils/memory.py @@ -22,7 +22,7 @@ import glob import math import logging -from avocado.utils import process +from . import process # Returns total memory in kb diff --git a/avocado/utils/path.py b/avocado/utils/path.py index 8553db75..3c761f7f 100644 --- a/avocado/utils/path.py +++ b/avocado/utils/path.py @@ -19,7 +19,7 @@ Avocado path related functions. import os import stat -from avocado.utils import aurl +from . import aurl PY_EXTENSIONS = ['.py'] diff --git a/avocado/utils/process.py b/avocado/utils/process.py index a3a15b16..8e78eaf9 100644 --- a/avocado/utils/process.py +++ b/avocado/utils/process.py @@ -34,8 +34,9 @@ except ImportError: import subprocess SUBPROCESS32_SUPPORT = False +from . import gdb + from avocado import runtime -from avocado.utils import gdb from avocado.core import exceptions log = logging.getLogger('avocado.test') diff --git a/avocado/utils/remote.py b/avocado/utils/remote.py index f78e85d8..634bd89f 100644 --- a/avocado/utils/remote.py +++ b/avocado/utils/remote.py @@ -21,7 +21,7 @@ import logging import time from avocado.core import output -from avocado.utils import process +from . import process LOG = logging.getLogger('avocado.test') diff --git a/avocado/utils/script.py b/avocado/utils/script.py index 12919981..ccde94b5 100644 --- a/avocado/utils/script.py +++ b/avocado/utils/script.py @@ -20,7 +20,7 @@ import os import tempfile import shutil -from avocado.utils import path as utils_path +from . import path as utils_path class Script(object): diff --git a/avocado/utils/software_manager.py b/avocado/utils/software_manager.py index 196eb3d6..91647cff 100644 --- a/avocado/utils/software_manager.py +++ b/avocado/utils/software_manager.py @@ -49,10 +49,10 @@ except ImportError: else: HAS_YUM_MODULE = True -from avocado.utils import process -from avocado.utils import data_factory -from avocado.utils import distro -from avocado.utils import path as utils_path +from . import process +from . import data_factory +from . import distro +from . import path as utils_path log = logging.getLogger('avocado.test') diff --git a/avocado/utils/virt.py b/avocado/utils/virt.py index 134585bb..2ce883b4 100644 --- a/avocado/utils/virt.py +++ b/avocado/utils/virt.py @@ -19,7 +19,7 @@ Module to provide classes for Virtual Machines. import logging from xml.dom import minidom -from avocado.utils import remote +from . import remote LOG = logging.getLogger('avocado.test') -- GitLab