File: ansible-requirements.py

package info (click to toggle)
ansible-core 2.19.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,840 kB
  • sloc: python: 181,406; cs: 4,929; sh: 4,630; xml: 34; makefile: 21
file content (28 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (2)
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
from __future__ import annotations

import re


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()