summaryrefslogtreecommitdiffstats
path: root/test cases/common/14 configure file/file_contains.py
blob: 409f09c65e5d65b664956456ff2cd5a968139c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3

import sys
import argparse

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('file', nargs=1, type=str)
    parser.add_argument('text', nargs=1, type=str)
    args = parser.parse_args()

    text = args.text[0]

    with open(args.file[0], encoding='utf-8') as f:
        for line in f:
            if line.strip() == text:
                return 0

    return 1

if __name__ == '__main__':
    sys.exit(main())