summaryrefslogtreecommitdiffstats
path: root/test/sanity/code-smell/ansible-requirements.py
blob: 4d1a652f2b152c5b737ea6251336537ec9320fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import annotations

import re
import sys


def read_file(path):
    try:
        with open(path, 'r') as f:
            return f.read()
    except Exception as ex:  # pylint: disable=broad-except
        print('%s:%d:%d: unable to read required file %s' % (path, 0, 0, re.sub(r'\s+', ' ', str(ex))))
        return None


def main():
    ORIGINAL_FILE = 'requirements.txt'
    VENDORED_COPY = 'test/lib/ansible_test/_data/requirements/ansible.txt'

    original_requirements = read_file(ORIGINAL_FILE)
    vendored_requirements = read_file(VENDORED_COPY)

    if original_requirements is not None and vendored_requirements is not None:
        if original_requirements != vendored_requirements:
            print('%s:%d:%d: must be identical to %s' % (VENDORED_COPY, 0, 0, ORIGINAL_FILE))


if __name__ == '__main__':
    main()