# HG changeset patch # User Björn Ricks # Date 1381478937 -7200 # Node ID f21c1fe3b20bae06a4b8cad09684b43527d0a9fb # Parent 97892fea9ecdfc1ca70f28778413a6a15b8a987d Fix codingstyle for pep8 diff -r 97892fea9ecd -r f21c1fe3b20b getan/utils.py --- a/getan/utils.py Fri Oct 11 10:08:46 2013 +0200 +++ b/getan/utils.py Fri Oct 11 10:08:57 2013 +0200 @@ -12,12 +12,13 @@ global DATETIME_FORMAT DATETIME_FORMAT = "%Y-%m-%d" -TIME_FORMAT = "%H:%M:%S" +TIME_FORMAT = "%H:%M:%S" logger = logging.getLogger() + def human_time(seconds): - if seconds == None or seconds == 0: + if seconds is None or seconds == 0: return "--:--:--" s = seconds % 60 seconds /= 60 @@ -26,6 +27,7 @@ out = "%02d:%02d:%02d" % (seconds, m, s) return out + def safe_int(s, default=0): try: return int(s) @@ -35,7 +37,8 @@ def short_time(seconds): if seconds is None: - logger.warn("short_time(): No seconds given to format to 'short_time'.") + logger.warn( + "short_time(): No seconds given to format to 'short_time'.") return "0:00h" seconds /= 60 m = seconds % 60 @@ -46,5 +49,6 @@ def format_datetime(datetime): return datetime.strftime(DATETIME_FORMAT) + def format_time(datetime): return datetime.strftime(TIME_FORMAT)