Additional review comments on black linkcheck/

This commit is contained in:
Chris Mayo 2020-06-03 20:06:36 +01:00
parent 6b3cb18546
commit cec9b78f5e
11 changed files with 37 additions and 33 deletions

View file

@ -197,8 +197,8 @@ class FileUrl(urlbase.UrlBase):
"""
if self.parent_url is not None and not self.parent_url.startswith("file:"):
msg = _(
"local files are only checked without parent URL or when "
"the parent URL is also a file"
"local files are only checked without parent URL or when"
" the parent URL is also a file"
)
raise LinkCheckerError(msg)
if self.is_directory():
@ -221,9 +221,9 @@ class FileUrl(urlbase.UrlBase):
if path != realpath:
self.add_warning(
_(
"The URL path %(path)r is not the same as the "
"system path %(realpath)r. You should always use "
"the system path in URLs."
"The URL path %(path)r is not the same as the"
" system path %(realpath)r. You should always use"
" the system path in URLs."
)
% {"path": path, "realpath": realpath},
tag=WARN_FILE_SYSTEM_PATH,

View file

@ -154,8 +154,8 @@ class MailtoUrl(urlbase.UrlBase):
if len(mail) > 256:
self.set_result(
_(
"Mail address `%(addr)s' too long. Allowed 256 chars, "
"was %(length)d chars."
"Mail address `%(addr)s' too long. Allowed 256 chars,"
" was %(length)d chars."
)
% {"addr": mail, "length": len(mail)},
valid=False,
@ -188,8 +188,8 @@ class MailtoUrl(urlbase.UrlBase):
if len(local) > 64:
self.set_result(
_(
"Local part of mail address `%(addr)s' too long. "
"Allowed 64 chars, was %(length)d chars."
"Local part of mail address `%(addr)s' too long."
" Allowed 64 chars, was %(length)d chars."
)
% {"addr": mail, "length": len(local)},
valid=False,
@ -199,8 +199,8 @@ class MailtoUrl(urlbase.UrlBase):
if len(domain) > 255:
self.set_result(
_(
"Domain part of mail address `%(addr)s' too long. "
"Allowed 255 chars, was %(length)d chars."
"Domain part of mail address `%(addr)s' too long."
" Allowed 255 chars, was %(length)d chars."
)
% {"addr": mail, "length": len(local)},
valid=False,
@ -249,8 +249,8 @@ class MailtoUrl(urlbase.UrlBase):
if char in local.replace("\\%s" % char, ""):
self.set_result(
_(
"Local part of mail address `%(addr)s' contains "
"unquoted character `%(char)s."
"Local part of mail address `%(addr)s' contains"
" unquoted character `%(char)s."
)
% {"addr": mail, "char": char},
valid=False,

View file

@ -432,8 +432,8 @@ def get_user_config():
shutil.copy(initialconf, userconf)
except Exception as errmsg:
msg = _(
"could not copy initial configuration file %(src)r "
"to %(dst)r: %(errmsg)r"
"could not copy initial configuration file %(src)r"
" to %(dst)r: %(errmsg)r"
)
args = dict(src=initialconf, dst=userconf, errmsg=errmsg)
log.warn(LOG_CHECK, msg % args)

View file

@ -233,9 +233,9 @@ class LCConfigParser(RawConfigParser):
if fileutil.is_accessable_by_others(fn):
log.warn(
LOG_CHECK,
"The configuration file %s contains password information (in "
"section [%s] and options %s) and the file is readable by "
"others. Please make the file only readable by you.",
"The configuration file %s contains password information (in"
" section [%s] and options %s) and the file is readable by"
" others. Please make the file only readable by you.",
fn,
section,
fields,
@ -246,8 +246,8 @@ class LCConfigParser(RawConfigParser):
log.warn(
LOG_CHECK,
_(
"See http://support.microsoft.com/kb/308419 for "
"more info on setting file permissions."
"See http://support.microsoft.com/kb/308419 for"
" more info on setting file permissions."
),
)

View file

@ -175,8 +175,8 @@ class Aggregate:
log.info(
LOG_CHECK,
_(
"%(num)d URLs are still active. After a timeout of %(timeout)s "
"the active URLs will stop."
"%(num)d URLs are still active. After a timeout of %(timeout)s"
" the active URLs will stop."
)
% args,
)

View file

@ -295,8 +295,7 @@ class HtmlLogger(_Logger):
sep = "<br/>" + os.linesep
text = sep.join(html.escape(x[1]) for x in url_data.warnings)
self.writeln(
'<tr><td class="warning" '
+ 'valign="top">'
'<tr><td class="warning" valign="top">'
+ self.part("warning")
+ '</td><td class="warning">'
+ text

View file

@ -91,7 +91,7 @@ if geoip_dat:
else:
def get_geoip_record(host):
return {
'country_name': geoip.country_name_by_name(host)
'country_name': geoip.country_name_by_name(host)
}

View file

@ -154,8 +154,8 @@ class RobotFileParser:
if state == 1:
log.debug(
LOG_CHECK,
"%r line %d: allow or disallow directives without any "
"user-agent line",
"%r line %d: allow or disallow directives without any"
" user-agent line",
self.url,
linenumber,
)
@ -180,8 +180,8 @@ class RobotFileParser:
if state == 2:
log.debug(
LOG_CHECK,
"%r line %d: missing blank line before "
"user-agent directive",
"%r line %d: missing blank line before"
" user-agent directive",
self.url,
linenumber,
)

View file

@ -338,8 +338,8 @@ def format_feature_warning(**kwargs):
"""
return (
_(
"Could not import %(module)s for %(feature)s. "
"Install %(module)s from %(url)s to use this feature."
"Could not import %(module)s for %(feature)s."
" Install %(module)s from %(url)s to use this feature."
)
% kwargs
)

View file

@ -60,12 +60,16 @@ _basic = {
"_hex_full": r"0-9a-f",
"_part": r"([a-z0-9][-a-z0-9]{0,61}|[a-z])",
}
_safe_char = r"([a-z0-9%(_path)s\+]|" r"(%%[%(_hex_safe)s][%(_hex_full)s]))" % _basic
_safe_char = (
r"([a-z0-9%(_path)s\+]|"
r"(%%[%(_hex_safe)s][%(_hex_full)s]))" % _basic
)
_safe_scheme_pattern = r"(https?|ftp)"
_safe_domain_pattern = r"(%(_part)s(\.%(_part)s)*\.?)" % _basic
_safe_host_pattern = _safe_domain_pattern + r"(:(80|8080|8000|443))?" % _basic
_safe_path_pattern = (
r"((/([a-z0-9%(_path)s]|" r"(%%[%(_hex_safe)s][%(_hex_full)s]))+)*/?)" % _basic
r"((/([a-z0-9%(_path)s]|"
r"(%%[%(_hex_safe)s][%(_hex_full)s]))+)*/?)" % _basic
)
_safe_fragment_pattern = r"%s*" % _safe_char
_safe_cgi = r"%s+(=(%s|/)+)?" % (_safe_char, _safe_char)

View file

@ -47,6 +47,7 @@ per-file-ignores =
linkcheck/ftpparse.py: E501
tests/test_ftpparse.py: E501
# F821 undefined name
# https://github.com/PyCQA/pyflakes/issues/548
linkcheck/logger/__init__.py: F821
extend-ignore =
# https://pep8.readthedocs.org/en/latest/intro.html#error-codes