elf2efi: make code more pythonic

Follow-up for 53628612b7.

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-05-14 15:09:09 +02:00
parent 798d140cac
commit c730fd7ddd

View File

@@ -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)