On Tue, 12 May 2020 at 09:17, <[email protected]> wrote:
> +        if d.getVar("CVE_CHECK_FORMAT_CSV") == "1":
> +            manifest_name += ".csv"
> +
> +            with open(cve_tmp_file, "r") as f:
> +                db_update_timestamp = f.readline()
> +                orig_tmp_file = f.readlines()[1:]
> +            with open(cve_tmp_file, "w") as f:
> +                f.write(db_update_timestamp+'\n')
> +                f.write("PACKAGE NAME;PACKAGE VERSION;CVE;CVE STATUS;"
> +                       "CVE SUMMARY;CVSS v2 BASE SCORE;CVSS v3 BASE SCORE;"
> +                       "VECTOR;MORE INFORMATION\n")

If writing a CSV file, it's really best to use the built-in csv writer
classes as they handle quoting and so on for you.

> +        write_string += "%s%s%c" % ("PACKAGE NAME: " if 
> d.getVar("CVE_CHECK_FORMAT_CSV") != "1" else "", d.getVar("PN"), eol_char)
> +        write_string += "%s%s%c" % ("PACKAGE VERSION: " if 
> d.getVar("CVE_CHECK_FORMAT_CSV") != "1" else "", d.getVar("PV"), eol_char)
> +        write_string += "%s%s%c" % ("CVE: " if 
> d.getVar("CVE_CHECK_FORMAT_CSV") != "1" else "", cve, eol_char)

This is getting unreadable.

How about having a report class and separate implementations for each
type, instead of trying to support both forms in the same code path?

Ross
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#138175): 
https://lists.openembedded.org/g/openembedded-core/message/138175
Mute This Topic: https://lists.openembedded.org/mt/74154523/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to