Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.1 kB
2
Indexable
Never
                with open(pathway, "r") as f:
                        txt = f.readlines()

                search_phrase = "[PASS"
                search_phrase1 = "[ERROR"
                search_phrase2 = "[FAIL"
                search_phrase3 = "[Manual Verification Required"
                pass_cnt = []
                error_cnt = []
                warn_cnt = []

                line_num = 0

                for line in txt:
                        line_num += 1
                        if search_phrase in line:
                                pass_cnt.append(line_num)
                        if search_phrase3 in line:
                                warn_cnt.append(line_num)
                                line = line.replace(search_phrase3, search_phrase)
                        if search_phrase1 in line or search_phrase2 in line:
                                error_cnt.append(line_num)

                # Close the file after saving the changes if needed
                with open(pathway,"w+") as f:
                        f.writelines(txt)