Debian Codegraph @

test/sanity/code-smell/ansible-requirements.py

raw
1 from __future__ import annotations
2
3 import re
4
5
6 def read_file(path):
7 try:
8 with open(path, 'r') as f:
9 return f.read()
10 except Exception as ex: # pylint: disable=broad-except
11 print('%s:%d:%d: unable to read required file %s' % (path, 0, 0, re.sub(r'\s+', ' ', str(ex))))
12 return None
13
14
15 def main():
16 ORIGINAL_FILE = 'requirements.txt'
17 VENDORED_COPY = 'test/lib/ansible_test/_data/requirements/ansible.txt'
18
19 original_requirements = read_file(ORIGINAL_FILE)
20 vendored_requirements = read_file(VENDORED_COPY)
21
22 if original_requirements is not None and vendored_requirements is not None:
23 if original_requirements != vendored_requirements:
24 print('%s:%d:%d: must be identical to %s' % (VENDORED_COPY, 0, 0, ORIGINAL_FILE))
25
26
27 if __name__ == '__main__':
28 main()