[diffoscope] 04/04: diffoscope.presenters.utils: Tidy "make_printer"
Chris Lamb
chris at chris-lamb.co.uk
Mon Jan 2 11:14:28 CET 2017
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit ea02b894ff5a7bf70ac67679536f0fcc0c4fe853
Author: Chris Lamb <lamby at debian.org>
Date: Mon Jan 2 10:12:56 2017 +0000
diffoscope.presenters.utils: Tidy "make_printer"
Signed-off-by: Chris Lamb <lamby at debian.org>
---
diffoscope/presenters/utils.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/diffoscope/presenters/utils.py b/diffoscope/presenters/utils.py
index 71a5746..5ee8883 100644
--- a/diffoscope/presenters/utils.py
+++ b/diffoscope/presenters/utils.py
@@ -93,14 +93,17 @@ def profiling(difference, parsed_args, has_differences):
@contextlib.contextmanager
def make_printer(path):
- if path == '-':
- output = sys.stdout
- else:
+ output = sys.stdout
+
+ if path != '-':
output = codecs.open(path, 'w', encoding='utf-8')
- def print_func(*args, **kwargs):
+
+ def fn(*args, **kwargs):
kwargs['file'] = output
print(*args, **kwargs)
- print_func.output = output
- yield print_func
+ fn.output = output
+
+ yield fn
+
if path != '-':
output.close()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list