From 98a3fba9402a84d00762eeeeb7086f855d8a0d0f Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 6 Aug 2022 23:56:40 +0200 Subject: [PATCH] support/scripts/pkg-stats: remove useless escaping of double quotes 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. Signed-off-by: Thomas Petazzoni Tested-By: Sen Hastings Acked-By: Sen Hastings --- 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){ -Results
+Results
""" # 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'
{pkg.path}
\n') + f.write(f'
{pkg.path}
\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'
{str(pkg.patch_count)}
\n') + f.write(f'
{str(pkg.patch_count)}
\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'
{infra_str(pkg.infras)}
\n') + f.write(f'
{infra_str(pkg.infras)}
\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'
{boolean_str(pkg.is_status_ok("license"))}
\n') + f.write(f'
{boolean_str(pkg.is_status_ok("license"))}
\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'
{boolean_str(pkg.is_status_ok("license-files"))}
\n') + f.write(f'
{boolean_str(pkg.is_status_ok("license-files"))}
\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'
{boolean_str(pkg.is_status_ok("hash"))}
\n') + f.write(f'
{boolean_str(pkg.is_status_ok("hash"))}
\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'
{current_version}
\n') + f.write(f'
{current_version}
\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'
{latest_version_text}
\n') + f.write(f'
{latest_version_text}
\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'
{pkg.warnings}
\n') + f.write(f'
{pkg.warnings}
\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 = "Link" % pkg.url - f.write(f'
{url_str}
\n') + f.write(f'
{url_str}
\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'
\n') + f.write(f'
\n') if len(pkg.cves) > 10: cve_total = len(pkg.cves) + 1 - f.write(f'
see all ({cve_total}) ▾
\n') + f.write(f'
see all ({cve_total}) ▾
\n') if pkg.is_status_error("cve"): for cve in pkg.cves: f.write(" %s
\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'
\n') + f.write(f'
\n') for ignored_cve in pkg.ignored_cves: f.write(" %s
\n" % (ignored_cve, ignored_cve)) f.write("
\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'
\n') + f.write(f'
\n') if pkg.cpeid: cpeid_begin = ":".join(pkg.cpeid.split(":")[0:4]) + ":" cpeid_formatted = pkg.cpeid.replace(cpeid_begin, cpeid_begin + "") @@ -1121,33 +1121,33 @@ def dump_html_pkg(f, pkg): def dump_html_all_pkgs(f, packages): f.write(""" -
-
Package
-
Patch count
-
Infrastructure
-
License
-
License files
-
Hash file
-
Current version
-
Latest version
-
Warnings
-
Upstream URL
-
CVEs
-
CVEs Ignored
-
CPE ID
+
+
Package
+
Patch count
+
Infrastructure
+
License
+
License files
+
Hash file
+
Current version
+
Latest version
+
Warnings
+
Upstream URL
+
CVEs
+
CVEs Ignored
+
CPE ID
""") for pkg in sorted(packages): dump_html_pkg(f, pkg)