diff options
Diffstat (limited to 'test cases/common/14 configure file/file_contains.py')
-rw-r--r-- | test cases/common/14 configure file/file_contains.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test cases/common/14 configure file/file_contains.py b/test cases/common/14 configure file/file_contains.py new file mode 100644 index 0000000..409f09c --- /dev/null +++ b/test cases/common/14 configure file/file_contains.py @@ -0,0 +1,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()) |