Commit 2c1b08be authored by Thomas Lotze's avatar Thomas Lotze

move some helper functions to the bottom of the module

parent abd3f339
......@@ -2,27 +2,6 @@ from collections import defaultdict
from gitlab import Gitlab
def parse_action(action):
op, time_str = action.split(None, 1)
sign = dict(added=1, subtracted=-1)[op]
value = sum(parse_time(piece) for piece in time_str.split())
return sign * value
def parse_time(time_str):
ulen = 2 if time_str.endswith('mo') else 1
value_str, unit_str = time_str[:-ulen], time_str[-ulen:]
unit = dict(
mo=576000,
w=144000,
d=28800,
h=3600,
m=60,
s=1,
)[unit_str]
return float(value_str) * unit
def fetch(url, token, filter):
"""Yield all relevant time tracking entries, in no particular order.
"""
......@@ -121,3 +100,24 @@ def fetch_times(item):
date = item.created_at.split('T')[0]
yield item.author['username'], date, seconds
def parse_action(action):
op, time_str = action.split(None, 1)
sign = dict(added=1, subtracted=-1)[op]
value = sum(parse_time(piece) for piece in time_str.split())
return sign * value
def parse_time(time_str):
ulen = 2 if time_str.endswith('mo') else 1
value_str, unit_str = time_str[:-ulen], time_str[-ulen:]
unit = dict(
mo=576000,
w=144000,
d=28800,
h=3600,
m=60,
s=1,
)[unit_str]
return float(value_str) * unit
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment