Paul Sokolovsky | 3c98fe0 | 2023-07-02 12:42:59 +0300 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (c) 2022 Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | |
| 7 | # Script to prepare a textual body of a comment to pass on the command line |
| 8 | # to Gerrit: limit it to acceptable size and quote properly. |
| 9 | |
| 10 | import sys |
| 11 | import shlex |
| 12 | |
| 13 | |
| 14 | SIZE_LIMIT = 16000 |
| 15 | |
| 16 | |
| 17 | body = "" |
| 18 | |
| 19 | with open(sys.argv[1], "r") as f: |
| 20 | for l in f: |
Paul Sokolovsky | 1721538 | 2023-08-03 14:41:04 +0300 | [diff] [blame] | 21 | if len(body) + len(l) >= SIZE_LIMIT: |
Paul Sokolovsky | 3c98fe0 | 2023-07-02 12:42:59 +0300 | [diff] [blame] | 22 | body += """\ |
| 23 | [...] |
| 24 | |
| 25 | WARNING: The report was trimmed due to size limit of a Gerrit comment. |
| 26 | Follow the link at the beginning to see the full report. |
| 27 | """ |
| 28 | break |
Paul Sokolovsky | 1721538 | 2023-08-03 14:41:04 +0300 | [diff] [blame] | 29 | body += l |
Paul Sokolovsky | 3c98fe0 | 2023-07-02 12:42:59 +0300 | [diff] [blame] | 30 | |
| 31 | sys.stdout.write(shlex.quote(body)) |