mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-05 13:14:46 +00:00
use preferred locale for default encoding
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2878 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
9873747d92
commit
50ea41b12d
5 changed files with 9 additions and 7 deletions
|
|
@ -154,7 +154,7 @@ acap # application configuration access protocol
|
||||||
|
|
||||||
ignored_schemes_re = re.compile(ignored_schemes, re.VERBOSE)
|
ignored_schemes_re = re.compile(ignored_schemes, re.VERBOSE)
|
||||||
|
|
||||||
_encoding = locale.getpreferredencoding()
|
_encoding = linkcheck.i18n.default_encoding
|
||||||
stderr = codecs.getwriter(_encoding)(sys.stderr, errors="ignore")
|
stderr = codecs.getwriter(_encoding)(sys.stderr, errors="ignore")
|
||||||
|
|
||||||
def internal_error ():
|
def internal_error ():
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ class StandardTest (unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
resultfile = self.get_file(filename+".result")
|
resultfile = self.get_file(filename+".result")
|
||||||
d = {'curdir': os.getcwd()}
|
d = {'curdir': os.getcwd()}
|
||||||
f = codecs.open(resultfile, "r", "iso8859-1")
|
f = codecs.open(resultfile, "r", linkcheck.i18n.default_encoding)
|
||||||
resultlines = [line.rstrip('\r\n') % d for line in f \
|
resultlines = [line.rstrip('\r\n') % d for line in f \
|
||||||
if line.strip() and not line.startswith(u'#')]
|
if line.strip() and not line.startswith(u'#')]
|
||||||
f.close()
|
f.close()
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import gettext
|
||||||
# more supported languages are added in init()
|
# more supported languages are added in init()
|
||||||
supported_languages = ['en']
|
supported_languages = ['en']
|
||||||
default_language = 'en'
|
default_language = 'en'
|
||||||
|
default_encoding = locale.getpreferredencoding()
|
||||||
|
|
||||||
def install_builtin (translator, do_unicode):
|
def install_builtin (translator, do_unicode):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import os
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import linkcheck.strformat
|
import linkcheck.strformat
|
||||||
|
import linkcheck.i18n
|
||||||
|
|
||||||
_ = lambda x: x
|
_ = lambda x: x
|
||||||
Fields = dict(
|
Fields = dict(
|
||||||
|
|
@ -69,8 +70,8 @@ class Logger (object):
|
||||||
# number of encountered warningss
|
# number of encountered warningss
|
||||||
self.warnings = 0
|
self.warnings = 0
|
||||||
# encoding of output
|
# encoding of output
|
||||||
preferred = locale.getpreferredencoding()
|
default = linkcheck.i18n.default_encoding
|
||||||
self.output_encoding = args.get("encoding", preferred)
|
self.output_encoding = args.get("encoding", default)
|
||||||
|
|
||||||
def init_fileoutput (self, args):
|
def init_fileoutput (self, args):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import linkcheck
|
||||||
optparse._ = _
|
optparse._ = _
|
||||||
# now import the rest of the linkchecker gang
|
# now import the rest of the linkchecker gang
|
||||||
import linkcheck.log
|
import linkcheck.log
|
||||||
|
import linkcheck.i18n
|
||||||
import linkcheck.checker
|
import linkcheck.checker
|
||||||
import linkcheck.checker.cache
|
import linkcheck.checker.cache
|
||||||
import linkcheck.checker.consumer
|
import linkcheck.checker.consumer
|
||||||
|
|
@ -301,8 +302,7 @@ class LCOptionParser (optparse.OptionParser, object):
|
||||||
s = u"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % (self.format_help(),
|
s = u"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % (self.format_help(),
|
||||||
Examples, LoggerTypes, RegularExpressions,
|
Examples, LoggerTypes, RegularExpressions,
|
||||||
ProxySupport, Notes, Retval, Warnings)
|
ProxySupport, Notes, Retval, Warnings)
|
||||||
encoding = locale.getpreferredencoding()
|
s = s.encode(linkcheck.i18n.default_encoding, "replace")
|
||||||
s = s.encode(encoding, "replace")
|
|
||||||
if os.name != 'posix':
|
if os.name != 'posix':
|
||||||
linkcheck.strformat.paginate(s)
|
linkcheck.strformat.paginate(s)
|
||||||
else:
|
else:
|
||||||
|
|
@ -541,7 +541,7 @@ if options.output:
|
||||||
if "/" in options.output:
|
if "/" in options.output:
|
||||||
logtype, encoding = options.output.split("/", 1)
|
logtype, encoding = options.output.split("/", 1)
|
||||||
else:
|
else:
|
||||||
logtype, encoding = options.output, "iso-8859-15"
|
logtype, encoding = options.output, linkcheck.i18n.default_encoding
|
||||||
if not linkcheck.Loggers.has_key(logtype.lower()):
|
if not linkcheck.Loggers.has_key(logtype.lower()):
|
||||||
print_usage(_("Unknown logger type %r in %r for option %s") % \
|
print_usage(_("Unknown logger type %r in %r for option %s") % \
|
||||||
(logtype, options.output, "'-o, --output'"))
|
(logtype, options.output, "'-o, --output'"))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue