From: Chris Laplante <[email protected]>

The goal is to make this more Pythonic, as it was a little cryptic the
first time I looked at it.

Signed-off-by: Chris Laplante <[email protected]>
---
 scripts/lib/devtool/standard.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 20c94616b2..0cdb9c6cfb 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -726,15 +726,13 @@ def _check_preserve(config, recipename):
 
 def get_staging_kver(srcdir):
     # Kernel version from work-shared
-    kerver = []
-    staging_kerVer=""
-    if os.path.exists(srcdir) and os.listdir(srcdir):
+    import itertools
+    try:
         with open(os.path.join(srcdir, "Makefile")) as f:
-            version = [next(f) for x in range(5)][1:4]
-            for word in version:
-                kerver.append(word.split('= ')[1].split('\n')[0])
-            staging_kerVer = ".".join(kerver)
-    return staging_kerVer
+            # Take VERSION, PATCHLEVEL, SUBLEVEL from lines 1, 2, 3
+            return ".".join(line.rstrip().split('= ')[1] for line in 
itertools.islice(f, 1, 4))
+    except FileNotFoundError:
+        return ""
 
 def get_staging_kbranch(srcdir):
     import bb.process
-- 
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#210406): 
https://lists.openembedded.org/g/openembedded-core/message/210406
Mute This Topic: https://lists.openembedded.org/mt/110882936/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to