From ee1bef43e92a3d517a3310848c9eebaf18dfa329 Mon Sep 17 00:00:00 2001 From: Marcus Müller <mmueller@gnuradio.org> Date: Sun, 21 Apr 2019 16:19:21 +0200 Subject: modtool core: Don't import CLI functionality unless CLI is used This allows usage of scripted modtool on systems without click installed. Only with this, headless unit testing can be done without installing click. --- gr-utils/python/modtool/core/base.py | 2 +- gr-utils/python/modtool/core/disable.py | 3 ++- gr-utils/python/modtool/core/rm.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'gr-utils/python/modtool') diff --git a/gr-utils/python/modtool/core/base.py b/gr-utils/python/modtool/core/base.py index 5d133892e6..f47fdd5ce6 100644 --- a/gr-utils/python/modtool/core/base.py +++ b/gr-utils/python/modtool/core/base.py @@ -33,7 +33,6 @@ from types import SimpleNamespace from gnuradio import gr from ..tools import get_modname, SCMRepoFactory -from ..cli import setup_cli_logger logger = logging.getLogger('gnuradio.modtool') @@ -90,6 +89,7 @@ class ModTool(object): self.info['yes'] = True else: self.info['yes'] = kwargs.get('yes', False) + from ..cli import setup_cli_logger setup_cli_logger(logger) if not type(self).__name__ in ['ModToolInfo', 'ModToolNewModule']: diff --git a/gr-utils/python/modtool/core/disable.py b/gr-utils/python/modtool/core/disable.py index ad1f78ef91..d9b3188c67 100644 --- a/gr-utils/python/modtool/core/disable.py +++ b/gr-utils/python/modtool/core/disable.py @@ -29,7 +29,6 @@ import re import sys import logging -from ..cli import cli_input from ..tools import CMakeFileEditor from .base import ModTool, ModToolException @@ -131,6 +130,8 @@ class ModToolDisable(ModTool): # This portion will be covered by the CLI if not self.cli: self.validate() + else: + from ..cli import cli_input # List of special rules: 0: subdir, 1: filename re match, 2: callback special_treatments = ( ('python', r'qa.+py$', _handle_py_qa), diff --git a/gr-utils/python/modtool/core/rm.py b/gr-utils/python/modtool/core/rm.py index 688aa59835..80011b15ba 100644 --- a/gr-utils/python/modtool/core/rm.py +++ b/gr-utils/python/modtool/core/rm.py @@ -31,7 +31,6 @@ import glob import logging from ..tools import remove_pattern_from_file, CMakeFileEditor -from ..cli import cli_input from .base import ModTool, ModToolException logger = logging.getLogger(__name__) @@ -57,6 +56,8 @@ class ModToolRemove(ModTool): # This portion will be covered by the CLI if not self.cli: self.validate() + else: + from ..cli import cli_input def _remove_cc_test_case(filename=None, ed=None): """ Special function that removes the occurrences of a qa*.cc file from the CMakeLists.txt. """ -- cgit v1.2.3