Skip to content

Commit

Permalink
Do not print duplicate file messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ESultanik committed Nov 21, 2022
1 parent 387ced4 commit 1eb20e5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions polyfile/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,18 @@ def main(argv=None):
with output_format.output_stream as output:
if output_format.output_format == "file":
istty = sys.stderr.isatty() and output.isatty() and logging.root.level <= logging.INFO
lines = set()
with KeyboardInterruptHandler():
for match in analyzer.magic_matches():
if istty:
log.clear_status()
output.write(f"{match!s}\n")
output.flush()
else:
output.write(f"{match!s}\n")
line = str(match)
if line not in lines:
lines.add(line)
if istty:
log.clear_status()
output.write(f"{line}\n")
output.flush()
else:
output.write(f"{line}\n")
if istty:
log.clear_status()
elif output_format.output_format in ("mime", "explain"):
Expand Down

0 comments on commit 1eb20e5

Please sign in to comment.