一个简单的gitlab时间跟踪消息解析器
gitlab-duration-parser的Python项目详细描述
Gitlab持续时间分析器
一个简单的gitlab时间跟踪消息解析器
基本原理
gitlab的api仍然是doesn't provide a reliable way of getting the time-tracking statistics,因此必须 手动分析问题和合并请求以获取详细信息。 目前只有估算和花费时间的总和可用。
时间跟踪notes
(用gitlab的行话来说是注释)有以下几种风格:
'added 2h of time spent at 2019-06-06''subtracted 3w 2d 1h of time spent at 2019-06-08'
API
模块只提供一个函数--parse(s)
。它返回秒数
基于提供的字符串。减法时返回负数
时间。如果分析错误,将返回0。
用法片段
importdatetimeimportgitlab_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 usablestr(datetime.timedelta(seconds=seconds*0.8))# Steve always rounds his times up# --> '1:36:00'
测试
获取tox
,支持的python解释器,只需:
tox