From fdcc372b5cee30134039da3e7fa07429a6151726 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 11 Oct 2019 08:56:44 +0200 Subject: With -c we shouldn't print found lines --- epubgrep.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/epubgrep.py b/epubgrep.py index b62c67a..d6e44cf 100755 --- a/epubgrep.py +++ b/epubgrep.py @@ -74,13 +74,14 @@ def grep_book(filename: str, pattern: str, flags: int, counting: bool=False, col printed_title = True # https://stackoverflow.com/a/33206814 # print("\033[31;1;4mHello\033[0m") - if color: - found_line = decoded_line.replace( - res.group(1), - "\033[31;1m" + res.group(1) + "\033[31;0m") - print('{}'.format(found_line)) - else: - print(decoded_line) + if not counting: + if color: + found_line = decoded_line.replace( + res.group(1), + "\033[31;1m" + res.group(1) + "\033[31;0m") + print('{}'.format(found_line)) + else: + print(decoded_line) if count > 0: print('Found: {}'.format(count)) -- cgit