

def __fromstring__(self, timestr):
    seconds = 0
    comps = {
        'second': 1,
        'minute': 60,
        'hour': 3600,
        'day': (3600 * 24),
        'week': ((3600 * 24) * 7),
        'month': ((3600 * 24) * 30),
        'year': ((3600 * 24) * 365),
    }
    for (k, v) in comps.items():
        try:
            match = re.match(re.compile(('.*?([0-9]+?) ' + k)), timestr)
            assert (match is not None)
            seconds += (float(match.group(1)) * v)
        except AssertionError:
            pass
    return seconds

dataset/ETHPy150Open KoffeinFlummi/Chronyk/chronyk/chronyk.py ChronykDelta.__fromstring__/original