mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-26 10:50:22 +00:00
Refactor sys.stdout wrapping into a function.
This commit is contained in:
parent
b845335628
commit
8da37a32ee
1 changed files with 10 additions and 2 deletions
|
|
@ -54,6 +54,14 @@ ContentTypes = dict(
|
|||
other=0,
|
||||
)
|
||||
|
||||
|
||||
def get_stdout_writer (encoding=i18n.default_encoding, errors='replace'):
|
||||
"""Get wrapped sys.stdout writer with given encoding and error
|
||||
handling."""
|
||||
Writer = codecs.getwriter(encoding)
|
||||
return Writer(sys.stdout, errors)
|
||||
|
||||
|
||||
class LogStatistics (object):
|
||||
"""Gather log statistics:
|
||||
- number of errors, warnings and valid links
|
||||
|
|
@ -199,8 +207,8 @@ class Logger (object):
|
|||
elif 'fd' in args:
|
||||
self.fd = args['fd']
|
||||
else:
|
||||
Writer = codecs.getwriter(self.output_encoding)
|
||||
self.fd = Writer(sys.stdout, self.codec_errors)
|
||||
self.fd = get_stdout_writer(encoding=self.output_encoding,
|
||||
errors=self.codec_errors)
|
||||
|
||||
def start_fileoutput (self):
|
||||
"""Start output to configured file."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue