Mercurial > getan
changeset 302:f21c1fe3b20b
Fix codingstyle for pep8
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 11 Oct 2013 10:08:57 +0200 |
parents | 97892fea9ecd |
children | c75eed90ae01 |
files | getan/utils.py |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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)