Commit ea2649a3 authored by hydrargyrum's avatar hydrargyrum

log-ts-diff: format adjustments

parent 90ed5f5b
......@@ -38,13 +38,13 @@ def duration_to_str(duration):
for attr in attrs:
factor = getattr(duration, attr)
if factor:
parts.append(f'{factor:+2d} {attr}')
parts.append(f'{factor:=+2d}{attrs[attr]}')
if duration.microseconds:
secs = duration.seconds + duration.microseconds / 1_000_000
parts.append(f'{secs:+6.3f}s')
parts.append(f'{secs:=+7.3f}s')
elif duration.seconds:
parts.append(f'{duration.seconds:+3d}')
parts.append(f'{duration.seconds:=+3d}s')
if not parts:
parts.append('+0')
......
......@@ -5,20 +5,22 @@ import subprocess
output = subprocess.check_output(
[pathlib.Path(__file__).with_name('ts-diff.py')],
[pathlib.Path(__file__).with_name('log-ts-diff.py')],
encoding='utf-8',
input='''
2020-11-09 19:24:08,582:FOO
EXTRA
2020-11-09 19:24:08,628:BAR
2020-11-09 19:24:08,351:BAZ
2020-11-09 19:24:09,351:QUX
LINE
'''.strip()
)
assert output == '''
2020-11-09 19:24:08,582:FOO
EXTRA
+0.046s :BAR
-0.277s :BAZ
+ 0.046s :BAR
- 0.277s :BAZ
+ 1s :QUX
LINE
'''.lstrip()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment