def search_in_file(self, filename): # , invert_match, no_filename, color): if not file_exists_and_readable(filename): return if file_helper.file_is_binary(filename): if self.search_in_binary_file(filename): yield search_result.BinarySearchResult(filename=filename) else: for line_nr, line, result in self.search_in_text_file(filename): yield search_result.TextSearchResult(line_number=line_nr, line=line, match=result, filename=filename)
def test_file_is_binary(): assert file_helper.file_is_binary('tests/data/simpte/helloworld')
def test_file_is_text(): assert not file_helper.file_is_binary( 'tests/data/simple/zen_of_python.txt')