Format codebase w/ black.
[kiosk.git] / utils.py
index 51a29e7680400268ea09ecda867df6ad41105545..fb22e4dd052acfa4731dc62a30b928084cb00051 100644 (file)
--- a/utils.py
+++ b/utils.py
@@ -3,9 +3,11 @@ import os
 import constants
 from datetime import datetime
 
+
 def timestamp():
     t = datetime.fromtimestamp(time.time())
-    return t.strftime('%d/%b/%Y:%H:%M:%S%Z')
+    return t.strftime("%d/%b/%Y:%H:%M:%S%Z")
+
 
 def describe_age_of_file(filename):
     try:
@@ -16,6 +18,7 @@ def describe_age_of_file(filename):
     except Exception as e:
         return "?????"
 
+
 def describe_age_of_file_briefly(filename):
     try:
         now = time.time()
@@ -25,39 +28,42 @@ def describe_age_of_file_briefly(filename):
     except Exception as e:
         return "?????"
 
+
 def describe_duration(age):
     days = divmod(age, constants.seconds_per_day)
     hours = divmod(days[1], constants.seconds_per_hour)
     minutes = divmod(hours[1], constants.seconds_per_minute)
 
     descr = ""
-    if (days[0] > 1):
+    if days[0] > 1:
         descr = "%d days, " % days[0]
-    elif (days[0] == 1):
+    elif days[0] == 1:
         descr = "1 day, "
-    if (hours[0] > 1):
+    if hours[0] > 1:
         descr = descr + ("%d hours, " % hours[0])
-    elif (hours[0] == 1):
+    elif hours[0] == 1:
         descr = descr + "1 hour, "
-    if (len(descr) > 0):
+    if len(descr) > 0:
         descr = descr + "and "
-    if (minutes[0] == 1):
+    if minutes[0] == 1:
         descr = descr + "1 minute"
     else:
         descr = descr + ("%d minutes" % minutes[0])
     return descr
 
+
 def describe_duration_briefly(age):
     days = divmod(age, constants.seconds_per_day)
     hours = divmod(days[1], constants.seconds_per_hour)
     minutes = divmod(hours[1], constants.seconds_per_minute)
     descr = ""
-    if (days[0] > 0):
+    if days[0] > 0:
         descr = "%dd " % days[0]
-    if (hours[0] > 0):
+    if hours[0] > 0:
         descr = descr + ("%dh " % hours[0])
     descr = descr + ("%dm" % minutes[0])
     return descr
 
-#x = describe_age_of_file_briefly("pages/clock_10_none.html")
-#print x
+
+# x = describe_age_of_file_briefly("pages/clock_10_none.html")
+# print x