- commit
- f4d37910a529f9be6d798a2412a8ddde36384abd
- parent
- 1e7c06aafe5032f8038597f10a70238a4134121a
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-02-25 13:52
add --check
Diffstat
| M | vtimelog | 38 | ++++++++++++++++++++++++-------------- |
1 files changed, 24 insertions, 14 deletions
diff --git a/vtimelog b/vtimelog
@@ -217,6 +217,8 @@ if __name__ == '__main__': 217 217 help='show entries from this month or MONTH months ago') 218 218 parser.add_argument('-y', '--year', nargs='?', const=0, type=int, 219 219 help='show entries from this year or YEAR years ago') -1 220 parser.add_argument('-c', '--check', action='store_true', -1 221 help='find potential issues') 220 222 args = parser.parse_args() 221 223 222 224 # load data from file @@ -243,17 +245,25 @@ if __name__ == '__main__': 243 245 (data[-1]['dt'] - data[0]['dt']).total_seconds() / 3600 / 24 244 246 ) 245 247246 -1 extractor = Extractor(q.all())247 -1248 -1 # output by comment249 -1 by_comment = extractor.by_comment()250 -1 if len(by_comment) > 0:251 -1 length = max(len(k) for k in by_comment.keys())252 -1 for comment, delta in sorted(by_comment.items(), key=lambda a: a[1]):253 -1 padding = ' ' * (length + 1 - len(comment))254 -1 print(comment + padding + timedelta2str(delta))255 -1 print()256 -1257 -1 # output total workhours258 -1 done = int(extractor.sum().total_seconds() / 3600)259 -1 print('Total workhours done: %i (%i extra)' % (done, done - expected))-1 248 if args.check: -1 249 for entry, prev in pairwise(q.all()): -1 250 delta = entry['dt'] - prev['dt'] -1 251 if delta < timedelta(0) or ( -1 252 '**' not in entry['comment'] and delta > timedelta(hours=12) -1 253 ): -1 254 print(entry['dt'].strftime(DT_FORMAT) + ': ' + entry['comment']) -1 255 else: -1 256 extractor = Extractor(q.all()) -1 257 -1 258 # output by comment -1 259 by_comment = extractor.by_comment() -1 260 if len(by_comment) > 0: -1 261 length = max(len(k) for k in by_comment.keys()) -1 262 for comment, delta in sorted(by_comment.items(), key=lambda a: a[1]): -1 263 padding = ' ' * (length + 1 - len(comment)) -1 264 print(comment + padding + timedelta2str(delta)) -1 265 print() -1 266 -1 267 # output total workhours -1 268 done = int(extractor.sum().total_seconds() / 3600) -1 269 print('Total workhours done: %i (%i extra)' % (done, done - expected))