diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2019-10-11 08:56:44 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2019-10-11 08:56:44 +0200 |
commit | fdcc372b5cee30134039da3e7fa07429a6151726 (patch) | |
tree | 9ca93915328e87f004bb214bab65ef6d82f38a93 /epubgrep.py | |
parent | a0da6a4eb3c8ef5111531ffa81f911924ba2fd3d (diff) | |
download | epubgrep-fdcc372b5cee30134039da3e7fa07429a6151726.tar.gz |
With -c we shouldn't print found lines
Diffstat (limited to 'epubgrep.py')
-rwxr-xr-x | epubgrep.py | 15 |
1 files 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)) |