コード例 #1
0
ファイル: regex_searcher.py プロジェクト: derphilipp/pwgrep
    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)
コード例 #2
0
ファイル: regex_searcher.py プロジェクト: derphilipp/pwgrep
    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)
コード例 #3
0
def test_file_is_binary():
    assert file_helper.file_is_binary('tests/data/simpte/helloworld')
コード例 #4
0
def test_file_is_text():
    assert not file_helper.file_is_binary(
        'tests/data/simple/zen_of_python.txt')