[elbe-devel] [PATCH 2/9] elbepack: main: move get_cmdlist() helper

Thomas Weißschuh thomas.weissschuh at linutronix.de
Thu Jul 25 11:47:12 CEST 2024


Future changes would lead to a circular import otherwise.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 docs/conf.py            | 4 ++--
 elbepack/directories.py | 7 -------
 elbepack/main.py        | 7 ++++++-
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 7bb2ad9c4485..1e2676898430 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -23,7 +23,7 @@ import sys
 sys.path.insert(0, os.path.abspath('ext'))
 sys.path.insert(0, os.path.abspath('..'))
 
-import elbepack.directories  # noqa: E402
+import elbepack.main  # noqa: E402
 from elbepack.version import elbe_version  # noqa: E402
 
 # -- General configuration ------------------------------------------------
@@ -159,7 +159,7 @@ man_pages = [
     ('elbe', 'elbe', '', [], 1),
 ] + [
     ('elbe-' + cmd, 'elbe-' + cmd, '', [], 1)
-    for cmd in elbepack.directories.get_cmdlist()
+    for cmd in elbepack.main.get_cmdlist()
     if cmd not in {'bootup-check', 'check-build', 'pin_versions'}
 ]
 
diff --git a/elbepack/directories.py b/elbepack/directories.py
index 53d98741cde8..8c5d5caac75d 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -4,13 +4,6 @@
 
 import subprocess
 import sys
-from pkgutil import iter_modules
-
-import elbepack.commands
-
-
-def get_cmdlist():
-    return [x for _, x, _ in iter_modules(elbepack.commands.__path__)]
 
 
 def run_elbe(args, **kwargs):
diff --git a/elbepack/main.py b/elbepack/main.py
index 6e2217b3f2bb..7719dd9470f5 100644
--- a/elbepack/main.py
+++ b/elbepack/main.py
@@ -3,12 +3,17 @@
 # SPDX-FileCopyrightText: 2013-2017 Linutronix GmbH
 
 import importlib
+import pkgutil
 import sys
 
-from elbepack.directories import get_cmdlist
+import elbepack.commands
 from elbepack.version import elbe_version
 
 
+def get_cmdlist():
+    return [x for _, x, _ in pkgutil.iter_modules(elbepack.commands.__path__)]
+
+
 def usage():
     print('elbe v%s' % elbe_version)
     print("need a subcommand: e.g. \'elbe initvm\'. \n\

-- 
2.45.2



More information about the elbe-devel mailing list