[elbe-devel] [PATCH 4/4] elbepack: drop function init_directories
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Wed Feb 28 13:48:41 CET 2024
Instead of having to call init_directories() manually during startup use
the __main__ module to do the same automatically.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbe | 8 +-------
elbepack/directories.py | 15 ++++-----------
2 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/elbe b/elbe
index 77b15be46a4c..d688b5d105f2 100755
--- a/elbe
+++ b/elbe
@@ -13,7 +13,7 @@ import sys
# this file
#
import elbepack.commands # noqa: F401
-from elbepack.directories import get_cmdlist, init_directories
+from elbepack.directories import get_cmdlist
from elbepack.version import elbe_version
@@ -24,12 +24,6 @@ def usage():
for i in get_cmdlist():
print(' * %s' % i)
-# First initialise the directories module
-# so that it knows, where the current elbe
-# executable can be found.
-
-
-init_directories(__file__)
if len(sys.argv) < 2:
usage()
diff --git a/elbepack/directories.py b/elbepack/directories.py
index f3168ee3da23..6a2e698aa5fd 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -2,23 +2,16 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2015, 2017 Linutronix GmbH
+import __main__
import os
from pkgutil import iter_modules
import elbepack
-elbe_exe = None
-elbe_dir = None
-
-def init_directories(elbe_relpath):
- # set global variables that are used in other modules via imports
- # this is the very first function that is called by 'elbe'
- global elbe_exe
- global elbe_dir
-
- elbe_exe = os.path.abspath(os.path.realpath(elbe_relpath))
- elbe_dir = os.path.dirname(elbe_exe)
+# set global variables that are used in other modules via imports
+elbe_exe = os.path.abspath(os.path.realpath(__main__.__file__))
+elbe_dir = os.path.dirname(elbe_exe)
def get_cmdlist():
--
2.44.0
More information about the elbe-devel
mailing list