diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-12-06 12:24:06 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-12-06 12:24:06 +0000 |
| commit | 2dd05b00563bfc8818f5242b2fa27f5f14a07aa9 (patch) | |
| tree | a11cbc685fa74a4179eb15f15dcd88270a0454f3 /scripts | |
| parent | 32fd0edac3411bf4eaaae4001b7f251bf6d7d291 (diff) | |
Only print unique messages in CLI
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/mammoth | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/scripts/mammoth b/scripts/mammoth index f4865fb..be7ad10 100644 --- a/scripts/mammoth +++ b/scripts/mammoth @@ -34,14 +34,24 @@ def main(): convert_image=convert_image, output_format=args.output_format, ) - for message in result.messages: - sys.stderr.write(message.message) + for message in _unique([message.message for message in result.messages]): + sys.stderr.write(message) sys.stderr.write("\n") with _open_output(output_path) as output: output.write(result.value) +def _unique(values): + output = [] + seen = set() + for value in values: + if value not in seen: + seen.add(value) + output.append(value) + return output + + class ImageWriter(object): def __init__(self, output_dir): self._output_dir = output_dir |
