Debian Codegraph @

.azure-pipelines/scripts/time-command.py

raw symbols SCIP
1 #!/usr/bin/env python
2 """Prepends a relative timestamp to each input line from stdin and writes it to stdout."""
3
4 from __future__ import annotations
5
6 import sys
7 import time
8
9
10 def main():
11 """Main program entry point."""
12 start = time.time()
13
14 sys.stdin.reconfigure(errors='surrogateescape')
15 sys.stdout.reconfigure(errors='surrogateescape')
16
17 for line in sys.stdin:
18 seconds = time.time() - start
19 sys.stdout.write('%02d:%02d %s' % (seconds // 60, seconds % 60, line))
20 sys.stdout.flush()
21
22
23 if __name__ == '__main__':
24 main()