soc/integration/common: simplify get_version
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 11 Feb 2020 16:16:24 +0000 (17:16 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 11 Feb 2020 16:16:24 +0000 (17:16 +0100)
litex/soc/integration/common.py

index a5ac066ac48e2bea8fd55ed8f5975fb171421d70..b43e8dfe3a8228e7f624b4d10240d51609787118 100644 (file)
@@ -20,12 +20,8 @@ def mem_decoder(address, size=0x10000000):
     return lambda a: (a[log2_int(size):] == (address >> log2_int(size)))
 
 def get_version(with_time=True):
-    if with_time:
-        return datetime.datetime.fromtimestamp(
-                time.time()).strftime("%Y-%m-%d %H:%M:%S")
-    else:
-        return datetime.datetime.fromtimestamp(
-                time.time()).strftime("%Y-%m-%d")
+    fmt = "%Y-%m-%d %H:%M:%S" if with_time else "%Y-%m-%d"
+    return datetime.datetime.fromtimestamp(time.time()).strftime(fmt)
 
 def get_mem_data(filename_or_regions, endianness="big", mem_size=None):
     # create memory regions