641 ) |
641 ) |
642 # read the file and split it into textlines |
642 # read the file and split it into textlines |
643 try: |
643 try: |
644 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn) |
644 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn) |
645 lines = text.splitlines(True) |
645 lines = text.splitlines(True) |
646 except (UnicodeError, OSError): |
646 except (OSError, UnicodeError): |
647 self.findProgress.setValue(progress) |
647 self.findProgress.setValue(progress) |
648 continue |
648 continue |
649 |
649 |
650 now = time.monotonic() |
650 now = time.monotonic() |
651 # now perform the search and display the lines found |
651 # now perform the search and display the lines found |
843 |
843 |
844 # read the file and split it into textlines |
844 # read the file and split it into textlines |
845 try: |
845 try: |
846 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn) |
846 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn) |
847 lines = text.splitlines(True) |
847 lines = text.splitlines(True) |
848 except (UnicodeError, OSError) as err: |
848 except (OSError, UnicodeError) as err: |
849 EricMessageBox.critical( |
849 EricMessageBox.critical( |
850 self, |
850 self, |
851 self.tr("Replace in Files"), |
851 self.tr("Replace in Files"), |
852 self.tr( |
852 self.tr( |
853 """<p>Could not read the file <b>{0}</b>.""" |
853 """<p>Could not read the file <b>{0}</b>.""" |
882 |
882 |
883 # write the file |
883 # write the file |
884 txt = "".join(lines) |
884 txt = "".join(lines) |
885 try: |
885 try: |
886 Utilities.writeEncodedFile(fn, txt, encoding) |
886 Utilities.writeEncodedFile(fn, txt, encoding) |
887 except (OSError, Utilities.CodingError, UnicodeError) as err: |
887 except (OSError, UnicodeError, Utilities.CodingError) as err: |
888 EricMessageBox.critical( |
888 EricMessageBox.critical( |
889 self, |
889 self, |
890 self.tr("Replace in Files"), |
890 self.tr("Replace in Files"), |
891 self.tr( |
891 self.tr( |
892 """<p>Could not save the file <b>{0}</b>.""" |
892 """<p>Could not save the file <b>{0}</b>.""" |