diff mbox series

[04/58] buildman: Move full-help processing to main

Message ID 20230702142639.1249681-5-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show
Series buildman: Refactor code and correct some pylint warnings | expand

Commit Message

Simon Glass July 2, 2023, 2:25 p.m. UTC
This does not need any of the control features. Move it out of main to
reduce the size of the do_buildman() function.

For Python 3.6 the -H feature will not work, but this does not seem to be
a huge problem, as it dates from 2016.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/buildman/control.py | 11 -----------
 tools/buildman/main.py    |  9 +++++++++
 2 files changed, 9 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index c890f778f501..b27a6b08477f 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -8,11 +8,6 @@  This holds the main control logic for buildman, when not running tests.
 """
 
 import multiprocessing
-try:
-    import importlib.resources
-except ImportError:
-    # for Python 3.6
-    import importlib_resources
 import os
 import shutil
 import sys
@@ -26,7 +21,6 @@  from patman import gitutil
 from patman import patchstream
 from u_boot_pylib import command
 from u_boot_pylib import terminal
-from u_boot_pylib import tools
 from u_boot_pylib.terminal import tprint
 
 TEST_BUILDER = None
@@ -177,11 +171,6 @@  def do_buildman(options, args, toolchains=None, make_func=None, brds=None,
     # Used so testing can obtain the builder: pylint: disable=W0603
     global TEST_BUILDER
 
-    if options.full_help:
-        with importlib.resources.path('buildman', 'README.rst') as readme:
-            tools.print_full_help(str(readme))
-        return 0
-
     gitutil.setup()
     col = terminal.Color()
 
diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 9c84e16e7df0..2253401709a8 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -6,6 +6,11 @@ 
 
 """See README for more information"""
 
+try:
+    from importlib.resources import files
+except ImportError:
+    # for Python 3.6
+    import importlib_resources
 import os
 import sys
 
@@ -19,6 +24,7 @@  from buildman import bsettings
 from buildman import cmdline
 from buildman import control
 from u_boot_pylib import test_util
+from u_boot_pylib import tools
 
 def run_tests(skip_net_tests, verbose, args):
     """Run the buildman tests
@@ -62,6 +68,9 @@  def run_buildman():
     if cmdline.HAS_TESTS and options.test:
         run_tests(options.skip_net_tests, options.verbose, args)
 
+    elif options.full_help:
+        tools.print_full_help(str(files('buildman').joinpath('README.rst')))
+
     # Build selected commits for selected boards
     else:
         bsettings.Setup(options.config_file)