]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
elf2efi: make code more pythonic
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 14 May 2025 13:09:09 +0000 (15:09 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 14 May 2025 16:35:21 +0000 (18:35 +0200)
Follow-up for 53628612b75b444681fabc729ad7b012299c4c63.

With 'or', we ignore the empty string (but not '0'), and we only call
time.time() lazily. So this works the same as the code that is replaced,
but avoids the ugly repetition.

tools/elf2efi.py

index fff2b1a4be40af399cc3cfbb72c02478024b19fb..d3ef5907b208f81e64545de70339a51ae2894c2a 100755 (executable)
@@ -611,9 +611,7 @@ def elf2efi(args: argparse.Namespace):
 
     coff.Machine = pe_arch
     coff.NumberOfSections = len(sections)
-    coff.TimeDateStamp = int(
-        os.environ.get("SOURCE_DATE_EPOCH") if os.environ.get("SOURCE_DATE_EPOCH") else time.time()
-    )
+    coff.TimeDateStamp = int(os.environ.get("SOURCE_DATE_EPOCH") or time.time())
     coff.SizeOfOptionalHeader = sizeof(opt)
     # EXECUTABLE_IMAGE|LINE_NUMS_STRIPPED|LOCAL_SYMS_STRIPPED|DEBUG_STRIPPED
     # and (32BIT_MACHINE or LARGE_ADDRESS_AWARE)