diff mbox series

[1/6] meta/lib/oe/sbom30.py: correct python list comprehension

Message ID 20241030050745.3702603-2-hongxu.jia@windriver.com
State Accepted, archived
Commit e13c54645bf716ddfb19606fd212cc349b570ad4
Headers show
Series Support SPDX include source for work-share directory | expand

Commit Message

Hongxu Jia Oct. 30, 2024, 5:07 a.m. UTC
The python list comprehension is not right for list:
>>> license_text_map = {'LicenseRef-FSF-Unlimited': 'http://spdx.org/spdxdocs/gettext-minimal-native-1fa0d5cb-2bb8-5631-9fab-cd219801733f/8d31e22acc4a8979f24dc24042692fb548fc8fc8d85d775ddac406abb122ceea/license-text/FSF-Unlimited'}
>>> license_text = ((k, license_text_map[k]) for k in sorted(license_text_map.keys()))
>>> print(license_text)
<generator object <genexpr> at 0x7f8575173270>
>>> [(k,v) for k, v in license_text]
[]

Change the () to [] to make it a list instead of a generator expression.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/lib/oe/sbom30.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Joshua Watt Oct. 31, 2024, 8:28 p.m. UTC | #1
LGTM

Reviewed-by: Joshua Watt <JPEWhacker@gmail.com>

On Tue, Oct 29, 2024 at 11:07 PM Hongxu Jia <hongxu.jia@windriver.com> wrote:
>
> The python list comprehension is not right for list:
> >>> license_text_map = {'LicenseRef-FSF-Unlimited': 'http://spdx.org/spdxdocs/gettext-minimal-native-1fa0d5cb-2bb8-5631-9fab-cd219801733f/8d31e22acc4a8979f24dc24042692fb548fc8fc8d85d775ddac406abb122ceea/license-text/FSF-Unlimited'}
> >>> license_text = ((k, license_text_map[k]) for k in sorted(license_text_map.keys()))
> >>> print(license_text)
> <generator object <genexpr> at 0x7f8575173270>
> >>> [(k,v) for k, v in license_text]
> []
>
> Change the () to [] to make it a list instead of a generator expression.
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>  meta/lib/oe/sbom30.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/lib/oe/sbom30.py b/meta/lib/oe/sbom30.py
> index 27ab5e45ac..8db90f30fd 100644
> --- a/meta/lib/oe/sbom30.py
> +++ b/meta/lib/oe/sbom30.py
> @@ -577,9 +577,9 @@ class ObjectSet(oe.spdx30.SHACLObjectSet):
>              re.sub(r"[^a-zA-Z0-9_-]", "_", license_expression),
>          ]
>
> -        license_text = (
> +        license_text = [
>              (k, license_text_map[k]) for k in sorted(license_text_map.keys())
> -        )
> +        ]
>
>          if not license_text:
>              lic = self.find_filter(
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/meta/lib/oe/sbom30.py b/meta/lib/oe/sbom30.py
index 27ab5e45ac..8db90f30fd 100644
--- a/meta/lib/oe/sbom30.py
+++ b/meta/lib/oe/sbom30.py
@@ -577,9 +577,9 @@  class ObjectSet(oe.spdx30.SHACLObjectSet):
             re.sub(r"[^a-zA-Z0-9_-]", "_", license_expression),
         ]
 
-        license_text = (
+        license_text = [
             (k, license_text_map[k]) for k in sorted(license_text_map.keys())
-        )
+        ]
 
         if not license_text:
             lic = self.find_filter(