aboutsummaryrefslogtreecommitdiffstats
path: root/epubgrep.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2019-10-11 08:56:44 +0200
committerMatěj Cepl <mcepl@cepl.eu>2019-10-11 08:56:44 +0200
commitfdcc372b5cee30134039da3e7fa07429a6151726 (patch)
tree9ca93915328e87f004bb214bab65ef6d82f38a93 /epubgrep.py
parenta0da6a4eb3c8ef5111531ffa81f911924ba2fd3d (diff)
downloadepubgrep-fdcc372b5cee30134039da3e7fa07429a6151726.tar.gz
With -c we shouldn't print found lines
Diffstat (limited to 'epubgrep.py')
-rwxr-xr-xepubgrep.py15
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))