From 6ef488ae803381e4059e609e8d99e766cfe32675 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 18 Nov 2011 23:34:38 +0100 Subject: Add some __doc__ to the parse from/to str/secs methods --- src/common.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common.py b/src/common.py index fdad77a9..a30c344f 100644 --- a/src/common.py +++ b/src/common.py @@ -194,6 +194,11 @@ def replace_key_with_bound(key): return key def parse_str_to_secs(duration=''): + """ + Parse a string of with a number of d, h, m, s + >>> parse_str_to_secs("1d3m1h") + 90180 + """ values = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400} result = 0 tmp = '0' @@ -211,6 +216,12 @@ def parse_str_to_secs(duration=''): return result def parse_secs_to_str(duration=0): + """ + Parse a number of seconds to a human-readable string. + The string has the form XdXhXmXs. 0 units are removed. + >>> parse_secs_to_str(3601) + 1h1s + """ secs, mins, hours, days = 0, 0, 0, 0 result = '' secs = duration % 60 -- cgit v1.2.3