Use f-strings or .format() over percent style
https://docs.astral.sh/ruff/rules/printf-string-formatting/ Signed-off-by: Alfred Wingate <parona@protonmail.com>
This commit is contained in:
@@ -157,7 +157,7 @@ def scan_url(pkg, urls, options, on_progress=None):
|
||||
else:
|
||||
output.eerror("Can't find a suitable handler!")
|
||||
except Exception as e:
|
||||
output.ewarn("Handler failed: [%s] %s" % (e.__class__.__name__, str(e)))
|
||||
output.ewarn(f"Handler failed: [{e.__class__.__name__}] {str(e)}")
|
||||
|
||||
if versions and CONFIG["oneshot"]:
|
||||
break
|
||||
|
@@ -81,7 +81,7 @@ def mangle_version(up_pv):
|
||||
pv = ".".join(groups)
|
||||
|
||||
if rc_part:
|
||||
pv = "%s_rc%s" % (pv, rc_part)
|
||||
pv = f"{pv}_rc{rc_part}"
|
||||
|
||||
return pv
|
||||
|
||||
@@ -157,13 +157,7 @@ def scan_pkg(pkg, options):
|
||||
if helpers.version_filtered(cp, m_ver, m_pv, cpan_vercmp):
|
||||
continue
|
||||
|
||||
url = "mirror://cpan/authors/id/%s/%s/%s/%s" % (
|
||||
version["cpanid"][0],
|
||||
version["cpanid"][0:1],
|
||||
version["cpanid"],
|
||||
version["archive"],
|
||||
)
|
||||
|
||||
url = f"mirror://cpan/authors/id/{version['cpanid'][0]}/{version['cpanid'][0:1]}/{version['cpanid']}/{version['archive']}"
|
||||
url = mangling.mangle_url(url, options)
|
||||
ret.append((url, pv, HANDLER_NAME, CONFIDENCE))
|
||||
|
||||
|
@@ -40,7 +40,7 @@ def scan_pkg(pkg, options):
|
||||
if helpers.version_filtered(cp, ver, pv):
|
||||
continue
|
||||
fp = urllib.request.urlopen(
|
||||
"http://freecode.com/projects/%s/releases/%s" % (package, release_id)
|
||||
f"http://freecode.com/projects/{package}/releases/{release_id}"
|
||||
)
|
||||
content = str(fp.read())
|
||||
download_page = re.findall(r'<a href="(/urls/[^"]+)"', content)[0]
|
||||
|
@@ -154,7 +154,7 @@ def scan_url(pkg, url, options):
|
||||
if CONFIG["scan-dir"]:
|
||||
for bu in SCANDIR_BLACKLIST_URLS:
|
||||
if re.match(bu, url):
|
||||
output.einfo("%s is blacklisted by rule %s" % (url, bu))
|
||||
output.einfo(f"{url} is blacklisted by rule {bu}")
|
||||
return []
|
||||
|
||||
resolved_url = helpers.parse_mirror(url)
|
||||
@@ -167,14 +167,15 @@ def scan_url(pkg, url, options):
|
||||
if ver not in resolved_url:
|
||||
newver = helpers.version_change_end_sep(ver)
|
||||
if newver and newver in resolved_url:
|
||||
output.einfo("Version: using %s instead of %s" % (newver, ver))
|
||||
output.einfo(f"Version: using {newver} instead of {ver}")
|
||||
ver = newver
|
||||
|
||||
template = helpers.template_from_url(resolved_url, ver)
|
||||
if "${" not in template:
|
||||
output.einfo(
|
||||
"Url doesn't seems to depend on version: %s not found in %s"
|
||||
% (ver, resolved_url)
|
||||
"Url doesn't seems to depend on version: {} not found in {}".format(
|
||||
ver, resolved_url
|
||||
)
|
||||
)
|
||||
return []
|
||||
else:
|
||||
@@ -201,12 +202,12 @@ def brute_force(pkg, url):
|
||||
|
||||
for bp in BRUTEFORCE_BLACKLIST_PACKAGES:
|
||||
if re.match(bp, cp):
|
||||
output.einfo("%s is blacklisted by rule %s" % (cp, bp))
|
||||
output.einfo(f"{cp} is blacklisted by rule {bp}")
|
||||
return []
|
||||
|
||||
for bp in BRUTEFORCE_BLACKLIST_URLS:
|
||||
if re.match(bp, url):
|
||||
output.einfo("%s is blacklisted by rule %s" % (cp, bp))
|
||||
output.einfo(f"{cp} is blacklisted by rule {bp}")
|
||||
return []
|
||||
|
||||
output.einfo("Generating version from " + ver)
|
||||
@@ -227,8 +228,7 @@ def brute_force(pkg, url):
|
||||
|
||||
if "${PV}" not in template:
|
||||
output.einfo(
|
||||
"Url doesn't seems to depend on full version: %s not found in %s"
|
||||
% (ver, url)
|
||||
f"Url doesn't seems to depend on full version: {ver} not found in {url}"
|
||||
)
|
||||
return []
|
||||
else:
|
||||
|
@@ -44,12 +44,11 @@ def scan_url(pkg, url, options):
|
||||
fnre = re.compile("^%s$" % re.escape(filename).replace(re.escape(ver), "(.*?)"))
|
||||
|
||||
output.einfo(
|
||||
"Using github API for: project=%s user=%s filename=%s"
|
||||
% (project, user, filename)
|
||||
f"Using github API for: project={project} user={user} filename={filename}"
|
||||
)
|
||||
|
||||
dlreq = urllib.request.urlopen(
|
||||
"https://api.github.com/repos/%s/%s/downloads" % (user, project)
|
||||
f"https://api.github.com/repos/{user}/{project}/downloads"
|
||||
)
|
||||
dls = json.load(dlreq)
|
||||
|
||||
|
@@ -42,7 +42,7 @@ def scan_pkg(pkg, options):
|
||||
package = options["data"]
|
||||
channel = options["type"]
|
||||
|
||||
url = "http://%s.php.net/rest/r/%s/allreleases.xml" % (channel, package.lower())
|
||||
url = f"http://{channel}.php.net/rest/r/{package.lower()}/allreleases.xml"
|
||||
|
||||
output.einfo("Using: " + url)
|
||||
|
||||
@@ -69,7 +69,7 @@ def scan_pkg(pkg, options):
|
||||
if helpers.version_filtered(cp, ver, pv):
|
||||
continue
|
||||
|
||||
url = "http://%s.php.net/get/%s-%s.tgz" % (channel, package, up_pv)
|
||||
url = f"http://{channel}.php.net/get/{package}-{up_pv}.tgz"
|
||||
url = mangling.mangle_url(url, options)
|
||||
|
||||
ret.append((url, pv, HANDLER_NAME, CONFIDENCE))
|
||||
|
@@ -42,7 +42,7 @@ def scan_url(pkg, url, options):
|
||||
gem = guess_gem(pkg.cpv, url)
|
||||
|
||||
if not gem:
|
||||
output.eerror("Can't guess gem name using %s and %s" % (pkg.cpv, url))
|
||||
output.eerror(f"Can't guess gem name using {pkg.cpv} and {url}")
|
||||
return []
|
||||
|
||||
output.einfo("Using RubyGem API: %s" % gem)
|
||||
@@ -75,7 +75,7 @@ def scan_pkg(pkg, options):
|
||||
pv = mangling.mangle_version(up_pv, options)
|
||||
if helpers.version_filtered(cp, ver, pv):
|
||||
continue
|
||||
url = "http://rubygems.org/gems/%s-%s.gem" % (gem, up_pv)
|
||||
url = f"http://rubygems.org/gems/{gem}-{up_pv}.gem"
|
||||
url = mangling.mangle_url(url, options)
|
||||
ret.append((url, pv, HANDLER_NAME, CONFIDENCE))
|
||||
return ret
|
||||
|
Reference in New Issue
Block a user