Debian Codegraph @

ansible_collections/community/general/tests/utils/clean-aliases-skips

raw
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 import re
7 import sys
8 from pathlib import Path
9
10
11 def sanitize(filepath, remotes_re):
12 with open(filepath) as fileread:
13 lines = fileread.readlines()
14
15 changed = False
16 out_lines = []
17 for ll in lines:
18 if not ll.startswith("skip/") or any(r.match(ll) for r in remotes_re):
19 out_lines.append(ll)
20 continue
21 changed = True
22
23 if changed:
24 print(f"sanitizing {filepath}", file=sys.stderr)
25 with open(filepath, "w") as filewrite:
26 filewrite.writelines(out_lines)
27
28
29 def main():
30 remotes = [x.strip() for x in sys.stdin.readlines()]
31 remotes.append("docker")
32
33 print(f"Valid remotes: {', '.join(remotes)}", file=sys.stderr)
34
35 remotes_re = [re.compile(rf"^skip/{r}(\s.*)?$") for r in remotes]
36
37 for filepath in Path("tests/integration/targets").glob("*/aliases"):
38 sanitize(filepath, remotes_re)
39
40
41 if __name__ == "__main__":
42 main()