- commit
- 1e7c06aafe5032f8038597f10a70238a4134121a
- parent
- c1df28af1b921643fdd931d64fba9a66e8d31984
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-02-25 15:03
Gardening
Diffstat
| M | vtimelog | 19 | ++++++++++--------- |
1 files changed, 10 insertions, 9 deletions
diff --git a/vtimelog b/vtimelog
@@ -54,8 +54,7 @@ def parse_line(line): 54 54 } 55 55 56 5657 -1 def datetime_add(dt, years=0, months=0, weeks=0, days=0, hours=0, minutes=0,58 -1 seconds=0, microseconds=0):-1 57 def datetime_add(dt, years=0, months=0, weeks=0, days=0, hours=0, minutes=0, seconds=0, microseconds=0): # noqa 59 58 dt += timedelta( 60 59 weeks=weeks, 61 60 days=days, @@ -194,13 +193,15 @@ class ExpectedHoursPer: 194 193 d1 = cls.day() 195 194 d2 = cls.year() / 365 196 195 fn = 2 / (1 + exp(-n / 7) / exp(-1 / 7)) - 1197 -1 d = (1-fn) * d1 + fn * d2-1 196 d = (1 - fn) * d1 + fn * d2 198 197 return d * n 199 198 200 199 @classmethod 201 200 def _workdays_per_year(cls):202 -1 return ((365 - cls.HOLIDAYS_PER_YEAR) * cls.WORKDAYS_PER_WEEK / 7203 -1 - cls.VACATION_DAYS_PER_YEAR)-1 201 return ( -1 202 (365 - cls.HOLIDAYS_PER_YEAR) * cls.WORKDAYS_PER_WEEK / 7 -1 203 - cls.VACATION_DAYS_PER_YEAR -1 204 ) 204 205 205 206 206 207 if __name__ == '__main__': @@ -220,8 +221,8 @@ if __name__ == '__main__': 220 221 221 222 # load data from file 222 223 with open(args.file) as fh:223 -1 l = [line.strip() for line in fh.readlines() if line.strip()]224 -1 data = LazyMap(l, parse_line)-1 224 lines = [line.strip() for line in fh.readlines() if line.strip()] -1 225 data = LazyMap(lines, parse_line) 225 226 226 227 # filter 227 228 q = Query(data) @@ -247,9 +248,9 @@ if __name__ == '__main__': 247 248 # output by comment 248 249 by_comment = extractor.by_comment() 249 250 if len(by_comment) > 0:250 -1 l = max(len(k) for k in by_comment.keys())-1 251 length = max(len(k) for k in by_comment.keys()) 251 252 for comment, delta in sorted(by_comment.items(), key=lambda a: a[1]):252 -1 padding = ' ' * (l + 1 - len(comment))-1 253 padding = ' ' * (length + 1 - len(comment)) 253 254 print(comment + padding + timedelta2str(delta)) 254 255 print() 255 256