Skip to content

Commit

Permalink
Set a fixed precision of 2 for float output. (#6)
Browse files Browse the repository at this point in the history
Improve formatting to have always a precision of 2 for floats.
  • Loading branch information
sallner authored Dec 11, 2023
1 parent 3c04903 commit 87dad2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ Change log
- Prefer exact matches in case of multiple ones.

- Fetch all projects, not just the first 100.

- Improve formatting to have always a precision of 2 for floats.
6 changes: 3 additions & 3 deletions gtimelog2tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,15 @@ def show_results(
for entry, resp, action in entries:
action = action.replace(' (dry run)', '')
if action == 'add':
print('ADD: {start} {amount:>8}: {comment}'.format(
print('ADD: {start} {amount:>8.2f}: {comment}'.format(
start=entry.start.isoformat(timespec='minutes'),
amount=entry.hours,
comment=entry.text,
), file=stdout)
totals['hours'][entry.task] += entry.hours
totals['entries'][entry.task] += 1
elif action == 'error':
print('ERR: {start} {amount:>8}: {comment}'.format(
print('ERR: {start} {amount:>8.2f}: {comment}'.format(
start=entry.start.isoformat(timespec='minutes'),
amount=entry.hours,
comment='; '.join(resp.get('errorMessages', [])),
Expand All @@ -466,7 +466,7 @@ def show_results(
print('TOTALS:', file=stdout)
for task, hours in sorted(totals['hours'].items()):
entries = totals['entries'][task]
print(f'{task}: {hours} h in {entries} entries.', file=stdout)
print(f'{task}: {hours:.2f} h in {entries} entries.', file=stdout)


def _main(argv=None, stdout=sys.stdout):
Expand Down

0 comments on commit 87dad2b

Please sign in to comment.