Debian Codegraph @

test/sanity/code-smell/release-names.py

raw
1 # -*- coding: utf-8 -*-
2 # (c) 2019, Ansible Project
3 #
4 # This file is part of Ansible
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 """
19 Test that the release name is present in the list of used up release names
20 """
21
22 from __future__ import annotations
23
24 import pathlib
25
26 from ansible.release import __codename__
27
28
29 def main():
30 """Entrypoint to the script"""
31
32 releases = pathlib.Path('.github/RELEASE_NAMES.txt').read_text().splitlines()
33
34 # Why this format? The file's sole purpose is to be read by a human when they need to know
35 # which release names have already been used. So:
36 # 1) It's easier for a human to find the release names when there's one on each line
37 # 2) It helps keep other people from using the file and then asking for new features in it
38 for name in (r.split(maxsplit=1)[1] for r in releases):
39 if __codename__ == name:
40 break
41 else:
42 print(f'.github/RELEASE_NAMES.txt: Current codename {__codename__!r} not present in the file')
43
44
45 if __name__ == '__main__':
46 main()