A simple Gitlab time-tracking message parser
Project description
gitlab-duration-parser
A simple Gitlab time-tracking message parser
Rationale
Gitlab's api still doesn't provide a reliable way of getting the time-tracking statistics so one has to manually parse the issues and merge requests in order to do get detailed information. Currently only the totals for estimates and spent time are available.
Time-tracking notes
(comments in Gitlab's jargon) come in the following flavors:
'added 2h of time spent at 2019-06-06'
'subtracted 3w 2d 1h of time spent at 2019-06-08'
API
The module provides only one function -- parse(s)
. It returns number of seconds
based on the provided string. It will return negative number in case of subtracting
time. In case of parsing error, 0 will be returned.
Usage snippet
import datetime
import gitlab_duration_parser
# get the message(s) from the Gitlab's api somehow (for example with python-gitlab package)
message = 'added 2h of time spent at 2019-06-06'
seconds = gitlab_duration_parser.parse(message)
# after calculations you can use datetime.timedelta(seconds=...)
# to convert the seconds back to something more usable
str(datetime.timedelta(seconds=seconds*0.8)) # Steve always rounds his times up
# --> '1:36:00'
Test
Get tox
, supported python interpreters and just:
tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for gitlab-duration-parser-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84215b29f8b5ce8eed2e8f638f9798f8a638ca5601978d92818f7b8a2d4bad04 |
|
MD5 | 5be21a0951898e41eb4adb168188ccdf |
|
BLAKE2b-256 | 77760b47f854e3951ff90af330138ef5975a036e627b4f4e838fddaae7024902 |