After commit [spdx 3.0: Rework how SPDX aliases are linked] applied, it set
license_text_map with SPDX alias other than actual ID

The property of simplelicensing_customIdToUri is 
ListProp(ObjectProp(DictionaryEntry))),
and class DictionaryEntry has key and value, the property of value is 
StringProp other
than ObjectProp in which could not support to decode/extract SPDX alias with 
actual ID
in image jsonld file
-----------
      "simplelicensing_customIdToUri": [
        {
          "type": "DictionaryEntry",
          "key": "LicenseRef-PD",
          "value": 
"http://spdxdocs.org/openembedded-alias/by-doc-hash/d53e90e23b12c4ad640809a74a810e86f31c76cdbdf36487712d22a33d53362a/sqlite3-native/UNIHASH/license-text/PD";
        }
      ],
-----------

This commit make StringProp to decode string as IRI first in which replace SPDX 
alias with
actual ID. For other situation, still return string as usual
-----------
      "simplelicensing_customIdToUri": [
        {
          "type": "DictionaryEntry",
          "key": "LicenseRef-PD",
          "value": 
"http://spdx.org/spdxdocs/sqlite3-native-e5cc0672-d8dd-57e8-a2df-fe4615831fda/162c62b5b011cd3f82f413b3dae4d6d1542201552c964d5ce69fe170e0720b85/license-text/PD";
        }
      ]
-----------

Signed-off-by: Hongxu Jia <[email protected]>
---
 meta/lib/oe/spdx30.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oe/spdx30.py b/meta/lib/oe/spdx30.py
index 5cd2eb45c3..160b55f84b 100644
--- a/meta/lib/oe/spdx30.py
+++ b/meta/lib/oe/spdx30.py
@@ -96,7 +96,12 @@ class StringProp(Property):
         encoder.write_string(value)
 
     def decode(self, decoder, *, objectset=None):
-        return decoder.read_string()
+        s = decoder.read_string()
+        if is_IRI(s) and objectset:
+            obj = objectset.find_by_id(s)
+            if obj is not None:
+                return obj._id
+        return s
 
 
 class AnyURIProp(StringProp):
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#208758): 
https://lists.openembedded.org/g/openembedded-core/message/208758
Mute This Topic: https://lists.openembedded.org/mt/110140303/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to