Debian Codegraph @

ansible_collections/community/general/.azure-pipelines/scripts/time-command.py

raw symbols SCIP
1 #!/usr/bin/env python
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 """Prepends a relative timestamp to each input line from stdin and writes it to stdout."""
7
8 from __future__ import annotations
9
10 import sys
11 import time
12
13
14 def main():
15 """Main program entry point."""
16 start = time.time()
17
18 sys.stdin.reconfigure(errors="surrogateescape")
19 sys.stdout.reconfigure(errors="surrogateescape")
20
21 for line in sys.stdin:
22 seconds = int(time.time() - start)
23 sys.stdout.write(f"{seconds // 60:02}:{seconds % 60:02} {line}")
24 sys.stdout.flush()
25
26
27 if __name__ == "__main__":
28 main()