* [Buildroot] [PATCH 2/2] support/scripts/pkg-stats: remove remaining double quote escaping
2022-08-06 21:56 [Buildroot] [PATCH 1/2] support/scripts/pkg-stats: remove useless escaping of double quotes Thomas Petazzoni via buildroot
@ 2022-08-06 21:56 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2022-08-06 21:56 UTC (permalink / raw)
To: buildroot; +Cc: Sen Hastings, Thomas Petazzoni
This is done either by switching to single quoted f-strings, triple
double quoted f-strings when needed, or simply single-quoted strings.
The renderer HTML is exactly identical before/after this commit.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
support/scripts/pkg-stats | 67 +++++++++++++++++++--------------------
1 file changed, 32 insertions(+), 35 deletions(-)
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 572757b7ea..aa3b49c809 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -1010,13 +1010,12 @@ def dump_html_pkg(f, pkg):
if pkg.latest_version['version'] is None:
latest_version_text = "<b>Found, but no version</b>"
else:
- latest_version_text = "<a href=\"https://release-monitoring.org/project/%s\"><b>%s</b></a>" % \
- (pkg.latest_version['id'], str(pkg.latest_version['version']))
+ latest_version_text = f"""<a href="https://release-monitoring.org/project/{pkg.latest_version['id']}"><b>{str(pkg.latest_version['version'])}</b></a>"""
latest_version_text += "<br/>"
if pkg.latest_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO:
- latest_version_text += "found by <a href=\"https://release-monitoring.org/distro/Buildroot/\">distro</a>"
+ latest_version_text += f'found by <a href="https://release-monitoring.org/distro/Buildroot/">distro</a>'
else:
latest_version_text += "found by guess"
@@ -1041,10 +1040,10 @@ def dump_html_pkg(f, pkg):
div_class.append("missing_url")
if pkg.status['url'][0] == "error":
div_class.append("invalid_url")
- url_str = "<a href=\"%s\">%s</a>" % (pkg.url, pkg.status['url'][1])
+ url_str = f"""<a href="{pkg.url}">{pkg.status['url'][1]}</a>"""
else:
div_class.append("good_url")
- url_str = "<a href=\"%s\">Link</a>" % pkg.url
+ url_str = f'<a href="{pkg.url}">Link</a>'
f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">{url_str}</div>\n')
# CVEs
@@ -1068,11 +1067,11 @@ def dump_html_pkg(f, pkg):
class="see-more centered cve_ignored">see all ({cve_total}) ▾</div>\n')
if pkg.is_status_error("cve"):
for cve in pkg.cves:
- f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s</a><br/>\n" % (cve, cve))
+ f.write(f' <a href="https://security-tracker.debian.org/tracker/{cve}">{cve}</a><br/>\n')
for cve in pkg.unsure_cves:
- f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s <i>(unsure)</i></a><br/>\n" % (cve, cve))
+ f.write(f' <a href="https://security-tracker.debian.org/tracker/{cve}">{cve} <i>(unsure)</i></a><br/>\n')
elif pkg.is_status_na("cve"):
- f.write(" %s" % pkg.status['cve'][1])
+ f.write(f""" {pkg.status['cve'][1]}""")
else:
f.write(" N/A\n")
f.write(" </div>\n")
@@ -1085,7 +1084,7 @@ def dump_html_pkg(f, pkg):
div_class.append("cve_ignored")
f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">\n')
for ignored_cve in pkg.ignored_cves:
- f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s</a><br/>\n" % (ignored_cve, ignored_cve))
+ f.write(f' <a href="https://security-tracker.debian.org/tracker/{ignored_cve}">{ignored_cve}</a><br/>\n')
f.write(" </div>\n")
# CPE ID
@@ -1108,11 +1107,9 @@ def dump_html_pkg(f, pkg):
if not pkg.is_status_ok("cpe"):
if pkg.is_actual_package and pkg.current_version:
if pkg.cpeid:
- f.write(" <br/>%s <a href=\"https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword=%s\">(Search)</a>\n" % # noqa: E501
- (pkg.status['cpe'][1], ":".join(pkg.cpeid.split(":")[0:5])))
+ f.write(f""" <br/>{pkg.status['cpe'][1]} <a href="https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword={":".join(pkg.cpeid.split(":")[0:5])}">(Search)</a>\n""") # noqa: E501
else:
- f.write(" %s <a href=\"https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword=%s\">(Search)</a>\n" % # noqa: E501
- (pkg.status['cpe'][1], pkg.name))
+ f.write(f""" {pkg.status['cpe'][1]} <a href="https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword={pkg.name}">(Search)</a>\n""") # noqa: E501
else:
f.write(" %s\n" % pkg.status['cpe'][1])
@@ -1155,49 +1152,49 @@ def dump_html_all_pkgs(f, packages):
def dump_html_stats(f, stats):
- f.write("<a id=\"results\"></a>\n")
- f.write("<div class=\"data\" id=\"results-grid\">\n")
+ f.write('<a id="results"></a>\n')
+ f.write('<div class="data" id="results-grid">\n')
infras = [infra[6:] for infra in stats.keys() if infra.startswith("infra-")]
for infra in infras:
- f.write(" <div class=\"data\">Packages using the <i>%s</i> infrastructure</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Packages using the <i>%s</i> infrastructure</div><div class="data">%s</div>\n' %
(infra, stats["infra-%s" % infra]))
- f.write(" <div class=\"data\">Packages having license information</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Packages having license information</div><div class="data">%s</div>\n' %
stats["license"])
- f.write(" <div class=\"data\">Packages not having license information</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Packages not having license information</div><div class="data">%s</div>\n' %
stats["no-license"])
- f.write(" <div class=\"data\">Packages having license files information</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Packages having license files information</div><div class="data">%s</div>\n' %
stats["license-files"])
- f.write(" <div class=\"data\">Packages not having license files information</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Packages not having license files information</div><div class="data">%s</div>\n' %
stats["no-license-files"])
- f.write(" <div class=\"data\">Packages having a hash file</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Packages having a hash file</div><div class="data">%s</div>\n' %
stats["hash"])
- f.write(" <div class=\"data\">Packages not having a hash file</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Packages not having a hash file</div><div class="data">%s</div>\n' %
stats["no-hash"])
- f.write(" <div class=\"data\">Total number of patches</div><div class=\"data\">%s</div>\n" %
+ f.write(' <div class="data">Total number of patches</div><div class="data">%s</div>\n' %
stats["patches"])
- f.write("<div class=\"data\">Packages having a mapping on <i>release-monitoring.org</i></div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages having a mapping on <i>release-monitoring.org</i></div><div class="data">%s</div>\n' %
stats["rmo-mapping"])
- f.write("<div class=\"data\">Packages lacking a mapping on <i>release-monitoring.org</i></div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages lacking a mapping on <i>release-monitoring.org</i></div><div class="data">%s</div>\n' %
stats["rmo-no-mapping"])
- f.write("<div class=\"data\">Packages that are up-to-date</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages that are up-to-date</div><div class="data">%s</div>\n' %
stats["version-uptodate"])
- f.write("<div class=\"data\">Packages that are not up-to-date</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages that are not up-to-date</div><div class="data">%s</div>\n' %
stats["version-not-uptodate"])
- f.write("<div class=\"data\">Packages with no known upstream version</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages with no known upstream version</div><div class="data">%s</div>\n' %
stats["version-unknown"])
- f.write("<div class=\"data\">Packages affected by CVEs</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages affected by CVEs</div><div class="data">%s</div>\n' %
stats["pkg-cves"])
- f.write("<div class=\"data\">Total number of CVEs affecting all packages</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Total number of CVEs affecting all packages</div><div class="data">%s</div>\n' %
stats["total-cves"])
- f.write("<div class=\"data\">Packages affected by unsure CVEs</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages affected by unsure CVEs</div><div class="data">%s</div>\n' %
stats["pkg-unsure-cves"])
- f.write("<div class=\"data\">Total number of unsure CVEs affecting all packages</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Total number of unsure CVEs affecting all packages</div><div class="data">%s</div>\n' %
stats["total-unsure-cves"])
- f.write("<div class=\"data\">Packages with CPE ID</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages with CPE ID</div><div class="data">%s</div>\n' %
stats["cpe-id"])
- f.write("<div class=\"data\">Packages without CPE ID</div><div class=\"data\">%s</div>\n" %
+ f.write('<div class="data">Packages without CPE ID</div><div class="data">%s</div>\n' %
stats["no-cpe-id"])
- f.write("</div>\n")
+ f.write('</div>\n')
def dump_html_gen_info(f, date, commit):
--
2.37.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/2] support/scripts/pkg-stats: remove useless escaping of double quotes
@ 2022-08-18 22:36 Sen Hastings
2022-08-18 22:36 ` [Buildroot] [PATCH 2/2] support/scripts/pkg-stats: remove remaining double quote escaping Sen Hastings
0 siblings, 1 reply; 3+ messages in thread
From: Sen Hastings @ 2022-08-18 22:36 UTC (permalink / raw)
To: buildroot; +Cc: Sen Hastings, Thomas Petazzoni
On 8/6/22 16:56, Thomas Petazzoni wrote:
> Within single-quoted f-strings, and within triple double quoted
> strings, escaping all the double quotes is completely useless and
> makes the code more difficult to read. Get rid of all this useless
> escaping.
>
> The renderer HTML is exactly identical before/after this commit.
Sorry for getting to this so late, I didn't realize for some reason
this was a patch. Looks all good.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-By: Sen Hastings <sen@phobosdpl.com>
Acked-By: Sen Hastings <sen@phobosdpl.com>
> ---
> support/scripts/pkg-stats | 100 +++++++++++++++++++-------------------
> 1 file changed, 50 insertions(+), 50 deletions(-)
>
> diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
> index d32abd7225..572757b7ea 100755
> --- a/support/scripts/pkg-stats
> +++ b/support/scripts/pkg-stats
> @@ -886,7 +886,7 @@ function expandField(fieldId){
>
> <body>
>
> -<a href=\"#results\">Results</a><br/>
> +<a href="#results">Results</a><br/>
>
> """ # noqa - tabs and spaces
>
> @@ -920,8 +920,8 @@ def boolean_str(b):
>
> def dump_html_pkg(f, pkg):
> pkg_css_class = pkg.path.replace("/", "_")[:-3]
> - f.write(f'<div id=\"package__{pkg_css_class}\" \
> - class=\"package data _{pkg_css_class}\">{pkg.path}</div>\n')
> + f.write(f'<div id="package__{pkg_css_class}" \
> + class="package data _{pkg_css_class}">{pkg.path}</div>\n')
> # Patch count
> data_field_id = f'patch_count__{pkg_css_class}'
> div_class = ["centered patch_count data"]
> @@ -932,8 +932,8 @@ def dump_html_pkg(f, pkg):
> div_class.append("somepatches")
> else:
> div_class.append("lotsofpatches")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)} \
> - \">{str(pkg.patch_count)}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)} \
> + ">{str(pkg.patch_count)}</div>\n')
>
> # Infrastructure
> data_field_id = f'infrastructure__{pkg_css_class}'
> @@ -944,8 +944,8 @@ def dump_html_pkg(f, pkg):
> div_class.append("wrong")
> else:
> div_class.append("correct")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)} \
> - \">{infra_str(pkg.infras)}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)} \
> + ">{infra_str(pkg.infras)}</div>\n')
>
> # License
> data_field_id = f'license__{pkg_css_class}'
> @@ -955,8 +955,8 @@ def dump_html_pkg(f, pkg):
> div_class.append("correct")
> else:
> div_class.append("wrong")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)} \
> - \">{boolean_str(pkg.is_status_ok("license"))}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)} \
> + ">{boolean_str(pkg.is_status_ok("license"))}</div>\n')
>
> # License files
> data_field_id = f'license_files__{pkg_css_class}'
> @@ -966,8 +966,8 @@ def dump_html_pkg(f, pkg):
> div_class.append("correct")
> else:
> div_class.append("wrong")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)} \
> - \">{boolean_str(pkg.is_status_ok("license-files"))}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)} \
> + ">{boolean_str(pkg.is_status_ok("license-files"))}</div>\n')
>
> # Hash
> data_field_id = f'hash_file__{pkg_css_class}'
> @@ -977,8 +977,8 @@ def dump_html_pkg(f, pkg):
> div_class.append("correct")
> else:
> div_class.append("wrong")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)} \
> - \">{boolean_str(pkg.is_status_ok("hash"))}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)} \
> + ">{boolean_str(pkg.is_status_ok("hash"))}</div>\n')
>
> # Current version
> data_field_id = f'current_version__{pkg_css_class}'
> @@ -986,8 +986,8 @@ def dump_html_pkg(f, pkg):
> current_version = pkg.current_version[:20] + "..."
> else:
> current_version = pkg.current_version
> - f.write(f' <div id=\"{data_field_id}\" \
> - class=\"centered current_version data _{pkg_css_class}\">{current_version}</div>\n')
> + f.write(f' <div id="{data_field_id}" \
> + class="centered current_version data _{pkg_css_class}">{current_version}</div>\n')
>
> # Latest version
> data_field_id = f'latest_version__{pkg_css_class}'
> @@ -1020,7 +1020,7 @@ def dump_html_pkg(f, pkg):
> else:
> latest_version_text += "found by guess"
>
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)}\">{latest_version_text}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">{latest_version_text}</div>\n')
>
> # Warnings
> data_field_id = f'warnings__{pkg_css_class}'
> @@ -1030,7 +1030,7 @@ def dump_html_pkg(f, pkg):
> div_class.append("correct")
> else:
> div_class.append("wrong")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)}\">{pkg.warnings}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">{pkg.warnings}</div>\n')
>
> # URL status
> data_field_id = f'upstream_url__{pkg_css_class}'
> @@ -1045,7 +1045,7 @@ def dump_html_pkg(f, pkg):
> else:
> div_class.append("good_url")
> url_str = "<a href=\"%s\">Link</a>" % pkg.url
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)}\">{url_str}</div>\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">{url_str}</div>\n')
>
> # CVEs
> data_field_id = f'cves__{pkg_css_class}'
> @@ -1061,11 +1061,11 @@ def dump_html_pkg(f, pkg):
> div_class.append("cve-ok")
> else:
> div_class.append("cve-unknown")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)}\">\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">\n')
> if len(pkg.cves) > 10:
> cve_total = len(pkg.cves) + 1
> - f.write(f' <div onclick=\"expandField(\'{data_field_id}\')\" \
> - class=\"see-more centered cve_ignored\">see all ({cve_total}) ▾</div>\n')
> + f.write(f' <div onclick="expandField(\'{data_field_id}\')" \
> + class="see-more centered cve_ignored">see all ({cve_total}) ▾</div>\n')
> if pkg.is_status_error("cve"):
> for cve in pkg.cves:
> f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s</a><br/>\n" % (cve, cve))
> @@ -1083,7 +1083,7 @@ def dump_html_pkg(f, pkg):
> div_class.append(f'_{pkg_css_class}')
> if pkg.ignored_cves:
> div_class.append("cve_ignored")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)}\">\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">\n')
> for ignored_cve in pkg.ignored_cves:
> f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s</a><br/>\n" % (ignored_cve, ignored_cve))
> f.write(" </div>\n")
> @@ -1100,7 +1100,7 @@ def dump_html_pkg(f, pkg):
> div_class.append("cpe-ok")
> else:
> div_class.append("cpe-unknown")
> - f.write(f' <div id=\"{data_field_id}\" class=\"{" ".join(div_class)}\">\n')
> + f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">\n')
> if pkg.cpeid:
> cpeid_begin = ":".join(pkg.cpeid.split(":")[0:4]) + ":"
> cpeid_formatted = pkg.cpeid.replace(cpeid_begin, cpeid_begin + "<wbr>")
> @@ -1121,33 +1121,33 @@ def dump_html_pkg(f, pkg):
>
> def dump_html_all_pkgs(f, packages):
> f.write("""
> -<div id=\"package-grid\">
> -<div style="grid-column: 1;" onclick="sortGrid(this.id)" id=\"package\"
> - class=\"package data label\"><span>Package</span><span></span></div>
> -<div style="grid-column: 2;" onclick="sortGrid(this.id)" id=\"patch_count\"
> - class=\"centered patch_count data label\"><span>Patch count</span><span></span></div>
> -<div style="grid-column: 3;" onclick="sortGrid(this.id)" id=\"infrastructure\"
> - class=\"centered infrastructure data label\">Infrastructure<span></span></div>
> -<div style="grid-column: 4;" onclick="sortGrid(this.id)" id=\"license\"
> - class=\"centered license data label\"><span>License</span><span></span></div>
> -<div style="grid-column: 5;" onclick="sortGrid(this.id)" id=\"license_files\"
> - class=\"centered license_files data label\"><span>License files</span><span></span></div>
> -<div style="grid-column: 6;" onclick="sortGrid(this.id)" id=\"hash_file\"
> - class=\"centered hash_file data label\"><span>Hash file</span><span></span></div>
> -<div style="grid-column: 7;" onclick="sortGrid(this.id)" id=\"current_version\"
> - class=\"centered current_version data label\"><span>Current version</span><span></span></div>
> -<div style="grid-column: 8;" onclick="sortGrid(this.id)" id=\"latest_version\"
> - class=\"centered latest_version data label\"><span>Latest version</span><span></span></div>
> -<div style="grid-column: 9;" onclick="sortGrid(this.id)" id=\"warnings\"
> - class=\"centered warnings data label\"><span>Warnings</span><span></span></div>
> -<div style="grid-column: 10;" onclick="sortGrid(this.id)" id=\"upstream_url\"
> - class=\"centered upstream_url data label\"><span>Upstream URL</span><span></span></div>
> -<div style="grid-column: 11;" onclick="sortGrid(this.id)" id=\"cves\"
> - class=\"centered cves data label\"><span>CVEs</span><span></span></div>
> -<div style="grid-column: 12;" onclick="sortGrid(this.id)" id=\"ignored_cves\"
> - class=\"centered ignored_cves data label\"><span>CVEs Ignored</span><span></span></div>
> -<div style="grid-column: 13;" onclick="sortGrid(this.id)" id=\"cpe_id\"
> - class=\"centered cpe_id data label\"><span>CPE ID</span><span></span></div>
> +<div id="package-grid">
> +<div style="grid-column: 1;" onclick="sortGrid(this.id)" id="package"
> + class="package data label"><span>Package</span><span></span></div>
> +<div style="grid-column: 2;" onclick="sortGrid(this.id)" id="patch_count"
> + class="centered patch_count data label"><span>Patch count</span><span></span></div>
> +<div style="grid-column: 3;" onclick="sortGrid(this.id)" id="infrastructure"
> + class="centered infrastructure data label">Infrastructure<span></span></div>
> +<div style="grid-column: 4;" onclick="sortGrid(this.id)" id="license"
> + class="centered license data label"><span>License</span><span></span></div>
> +<div style="grid-column: 5;" onclick="sortGrid(this.id)" id="license_files"
> + class="centered license_files data label"><span>License files</span><span></span></div>
> +<div style="grid-column: 6;" onclick="sortGrid(this.id)" id="hash_file"
> + class="centered hash_file data label"><span>Hash file</span><span></span></div>
> +<div style="grid-column: 7;" onclick="sortGrid(this.id)" id="current_version"
> + class="centered current_version data label"><span>Current version</span><span></span></div>
> +<div style="grid-column: 8;" onclick="sortGrid(this.id)" id="latest_version"
> + class="centered latest_version data label"><span>Latest version</span><span></span></div>
> +<div style="grid-column: 9;" onclick="sortGrid(this.id)" id="warnings"
> + class="centered warnings data label"><span>Warnings</span><span></span></div>
> +<div style="grid-column: 10;" onclick="sortGrid(this.id)" id="upstream_url"
> + class="centered upstream_url data label"><span>Upstream URL</span><span></span></div>
> +<div style="grid-column: 11;" onclick="sortGrid(this.id)" id="cves"
> + class="centered cves data label"><span>CVEs</span><span></span></div>
> +<div style="grid-column: 12;" onclick="sortGrid(this.id)" id="ignored_cves"
> + class="centered ignored_cves data label"><span>CVEs Ignored</span><span></span></div>
> +<div style="grid-column: 13;" onclick="sortGrid(this.id)" id="cpe_id"
> + class="centered cpe_id data label"><span>CPE ID</span><span></span></div>
> """)
> for pkg in sorted(packages):
> dump_html_pkg(f, pkg)
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 2/2] support/scripts/pkg-stats: remove remaining double quote escaping
2022-08-18 22:36 [Buildroot] [PATCH 1/2] support/scripts/pkg-stats: remove useless escaping of double quotes Sen Hastings
@ 2022-08-18 22:36 ` Sen Hastings
0 siblings, 0 replies; 3+ messages in thread
From: Sen Hastings @ 2022-08-18 22:36 UTC (permalink / raw)
To: buildroot; +Cc: Sen Hastings, Thomas Petazzoni
On 8/6/22 16:56, Thomas Petazzoni wrote:
> This is done either by switching to single quoted f-strings, triple
> double quoted f-strings when needed, or simply single-quoted strings.
>
> The renderer HTML is exactly identical before/after this commit.
>
yeah looks good.
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-By: Sen Hastings <sen@phobosdpl.com>
Acked-By: Sen Hastings <sen@phobosdpl.com>
> ---
> support/scripts/pkg-stats | 67 +++++++++++++++++++--------------------
> 1 file changed, 32 insertions(+), 35 deletions(-)
>
> diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
> index 572757b7ea..aa3b49c809 100755
> --- a/support/scripts/pkg-stats
> +++ b/support/scripts/pkg-stats
> @@ -1010,13 +1010,12 @@ def dump_html_pkg(f, pkg):
> if pkg.latest_version['version'] is None:
> latest_version_text = "<b>Found, but no version</b>"
> else:
> - latest_version_text = "<a href=\"https://release-monitoring.org/project/%s\"><b>%s</b></a>" % \
> - (pkg.latest_version['id'], str(pkg.latest_version['version']))
> + latest_version_text = f"""<a href="https://release-monitoring.org/project/{pkg.latest_version['id']}"><b>{str(pkg.latest_version['version'])}</b></a>"""
>
> latest_version_text += "<br/>"
>
> if pkg.latest_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO:
> - latest_version_text += "found by <a href=\"https://release-monitoring.org/distro/Buildroot/\">distro</a>"
> + latest_version_text += f'found by <a href="https://release-monitoring.org/distro/Buildroot/">distro</a>'
> else:
> latest_version_text += "found by guess"
>
> @@ -1041,10 +1040,10 @@ def dump_html_pkg(f, pkg):
> div_class.append("missing_url")
> if pkg.status['url'][0] == "error":
> div_class.append("invalid_url")
> - url_str = "<a href=\"%s\">%s</a>" % (pkg.url, pkg.status['url'][1])
> + url_str = f"""<a href="{pkg.url}">{pkg.status['url'][1]}</a>"""
> else:
> div_class.append("good_url")
> - url_str = "<a href=\"%s\">Link</a>" % pkg.url
> + url_str = f'<a href="{pkg.url}">Link</a>'
> f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">{url_str}</div>\n')
>
> # CVEs
> @@ -1068,11 +1067,11 @@ def dump_html_pkg(f, pkg):
> class="see-more centered cve_ignored">see all ({cve_total}) ▾</div>\n')
> if pkg.is_status_error("cve"):
> for cve in pkg.cves:
> - f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s</a><br/>\n" % (cve, cve))
> + f.write(f' <a href="https://security-tracker.debian.org/tracker/{cve}">{cve}</a><br/>\n')
> for cve in pkg.unsure_cves:
> - f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s <i>(unsure)</i></a><br/>\n" % (cve, cve))
> + f.write(f' <a href="https://security-tracker.debian.org/tracker/{cve}">{cve} <i>(unsure)</i></a><br/>\n')
> elif pkg.is_status_na("cve"):
> - f.write(" %s" % pkg.status['cve'][1])
> + f.write(f""" {pkg.status['cve'][1]}""")
> else:
> f.write(" N/A\n")
> f.write(" </div>\n")
> @@ -1085,7 +1084,7 @@ def dump_html_pkg(f, pkg):
> div_class.append("cve_ignored")
> f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">\n')
> for ignored_cve in pkg.ignored_cves:
> - f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s</a><br/>\n" % (ignored_cve, ignored_cve))
> + f.write(f' <a href="https://security-tracker.debian.org/tracker/{ignored_cve}">{ignored_cve}</a><br/>\n')
> f.write(" </div>\n")
>
> # CPE ID
> @@ -1108,11 +1107,9 @@ def dump_html_pkg(f, pkg):
> if not pkg.is_status_ok("cpe"):
> if pkg.is_actual_package and pkg.current_version:
> if pkg.cpeid:
> - f.write(" <br/>%s <a href=\"https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword=%s\">(Search)</a>\n" % # noqa: E501
> - (pkg.status['cpe'][1], ":".join(pkg.cpeid.split(":")[0:5])))
> + f.write(f""" <br/>{pkg.status['cpe'][1]} <a href="https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword={":".join(pkg.cpeid.split(":")[0:5])}">(Search)</a>\n""") # noqa: E501
> else:
> - f.write(" %s <a href=\"https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword=%s\">(Search)</a>\n" % # noqa: E501
> - (pkg.status['cpe'][1], pkg.name))
> + f.write(f""" {pkg.status['cpe'][1]} <a href="https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword={pkg.name}">(Search)</a>\n""") # noqa: E501
> else:
> f.write(" %s\n" % pkg.status['cpe'][1])
>
> @@ -1155,49 +1152,49 @@ def dump_html_all_pkgs(f, packages):
>
>
> def dump_html_stats(f, stats):
> - f.write("<a id=\"results\"></a>\n")
> - f.write("<div class=\"data\" id=\"results-grid\">\n")
> + f.write('<a id="results"></a>\n')
> + f.write('<div class="data" id="results-grid">\n')
> infras = [infra[6:] for infra in stats.keys() if infra.startswith("infra-")]
> for infra in infras:
> - f.write(" <div class=\"data\">Packages using the <i>%s</i> infrastructure</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Packages using the <i>%s</i> infrastructure</div><div class="data">%s</div>\n' %
> (infra, stats["infra-%s" % infra]))
> - f.write(" <div class=\"data\">Packages having license information</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Packages having license information</div><div class="data">%s</div>\n' %
> stats["license"])
> - f.write(" <div class=\"data\">Packages not having license information</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Packages not having license information</div><div class="data">%s</div>\n' %
> stats["no-license"])
> - f.write(" <div class=\"data\">Packages having license files information</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Packages having license files information</div><div class="data">%s</div>\n' %
> stats["license-files"])
> - f.write(" <div class=\"data\">Packages not having license files information</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Packages not having license files information</div><div class="data">%s</div>\n' %
> stats["no-license-files"])
> - f.write(" <div class=\"data\">Packages having a hash file</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Packages having a hash file</div><div class="data">%s</div>\n' %
> stats["hash"])
> - f.write(" <div class=\"data\">Packages not having a hash file</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Packages not having a hash file</div><div class="data">%s</div>\n' %
> stats["no-hash"])
> - f.write(" <div class=\"data\">Total number of patches</div><div class=\"data\">%s</div>\n" %
> + f.write(' <div class="data">Total number of patches</div><div class="data">%s</div>\n' %
> stats["patches"])
> - f.write("<div class=\"data\">Packages having a mapping on <i>release-monitoring.org</i></div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages having a mapping on <i>release-monitoring.org</i></div><div class="data">%s</div>\n' %
> stats["rmo-mapping"])
> - f.write("<div class=\"data\">Packages lacking a mapping on <i>release-monitoring.org</i></div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages lacking a mapping on <i>release-monitoring.org</i></div><div class="data">%s</div>\n' %
> stats["rmo-no-mapping"])
> - f.write("<div class=\"data\">Packages that are up-to-date</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages that are up-to-date</div><div class="data">%s</div>\n' %
> stats["version-uptodate"])
> - f.write("<div class=\"data\">Packages that are not up-to-date</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages that are not up-to-date</div><div class="data">%s</div>\n' %
> stats["version-not-uptodate"])
> - f.write("<div class=\"data\">Packages with no known upstream version</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages with no known upstream version</div><div class="data">%s</div>\n' %
> stats["version-unknown"])
> - f.write("<div class=\"data\">Packages affected by CVEs</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages affected by CVEs</div><div class="data">%s</div>\n' %
> stats["pkg-cves"])
> - f.write("<div class=\"data\">Total number of CVEs affecting all packages</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Total number of CVEs affecting all packages</div><div class="data">%s</div>\n' %
> stats["total-cves"])
> - f.write("<div class=\"data\">Packages affected by unsure CVEs</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages affected by unsure CVEs</div><div class="data">%s</div>\n' %
> stats["pkg-unsure-cves"])
> - f.write("<div class=\"data\">Total number of unsure CVEs affecting all packages</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Total number of unsure CVEs affecting all packages</div><div class="data">%s</div>\n' %
> stats["total-unsure-cves"])
> - f.write("<div class=\"data\">Packages with CPE ID</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages with CPE ID</div><div class="data">%s</div>\n' %
> stats["cpe-id"])
> - f.write("<div class=\"data\">Packages without CPE ID</div><div class=\"data\">%s</div>\n" %
> + f.write('<div class="data">Packages without CPE ID</div><div class="data">%s</div>\n' %
> stats["no-cpe-id"])
> - f.write("</div>\n")
> + f.write('</div>\n')
>
>
> def dump_html_gen_info(f, date, commit):
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-18 22:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-18 22:36 [Buildroot] [PATCH 1/2] support/scripts/pkg-stats: remove useless escaping of double quotes Sen Hastings
2022-08-18 22:36 ` [Buildroot] [PATCH 2/2] support/scripts/pkg-stats: remove remaining double quote escaping Sen Hastings
-- strict thread matches above, loose matches on Subject: below --
2022-08-06 21:56 [Buildroot] [PATCH 1/2] support/scripts/pkg-stats: remove useless escaping of double quotes Thomas Petazzoni via buildroot
2022-08-06 21:56 ` [Buildroot] [PATCH 2/2] support/scripts/pkg-stats: remove remaining double quote escaping Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox