From: Sen Hastings <sen@phobosdpl.com>
To: buildroot@buildroot.org
Cc: Sen Hastings <sen@phobosdpl.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [Buildroot] [PATCH 1/2] support/scripts/pkg-stats: remove useless escaping of double quotes
Date: Thu, 18 Aug 2022 17:36:02 -0500 [thread overview]
Message-ID: <20220818223603.45459-1-sen@phobosdpl.com> (raw)
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
next reply other threads:[~2022-08-18 22:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-18 22:36 Sen Hastings [this message]
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-24 11:37 ` Thomas Petazzoni via buildroot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220818223603.45459-1-sen@phobosdpl.com \
--to=sen@phobosdpl.com \
--cc=buildroot@buildroot.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox