main
Bob Mottram 2024-07-23 13:09:20 +01:00
parent ceee615da2
commit 395fbf8189
1 changed files with 6 additions and 5 deletions

View File

@ -22,16 +22,17 @@ def _text_in_file2(text: str, filename: str,
""" """
if not case_sensitive: if not case_sensitive:
text = text.lower() text = text.lower()
content = ''
try: try:
with open(filename, 'r', encoding='utf-8') as fp_file: with open(filename, 'r', encoding='utf-8') as fp_file:
content = fp_file.read() content = fp_file.read()
if content:
if not case_sensitive:
content = content.lower()
if text in content:
return True
except OSError: except OSError:
print('EX: unable to find text in missing file 2 ' + filename) print('EX: unable to find text in missing file 2 ' + filename)
if content:
if not case_sensitive:
content = content.lower()
if text in content:
return True
return False return False