Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-indexer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-indexer
Commits
fa0b1de2
Commit
fa0b1de2
authored
2 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
metadata_dictionary: Fix crash on null list item in an uri_field.
parent
a0fdaedd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/indexer/metadata_dictionary/base.py
+2
-1
2 additions, 1 deletion
swh/indexer/metadata_dictionary/base.py
swh/indexer/tests/metadata_dictionary/test_npm.py
+22
-0
22 additions, 0 deletions
swh/indexer/tests/metadata_dictionary/test_npm.py
with
24 additions
and
1 deletion
swh/indexer/metadata_dictionary/base.py
+
2
−
1
View file @
fa0b1de2
...
...
@@ -243,7 +243,8 @@ class DictMapping(BaseMapping):
graph
.
add
((
root
,
codemeta_key
,
rdflib
.
URIRef
(
v
)))
elif
k
in
self
.
uri_fields
and
isinstance
(
v
,
list
):
for
item
in
v
:
graph
.
add
((
root
,
codemeta_key
,
rdflib
.
URIRef
(
item
)))
if
isinstance
(
item
,
str
):
graph
.
add
((
root
,
codemeta_key
,
rdflib
.
URIRef
(
item
)))
else
:
continue
...
...
This diff is collapsed.
Click to expand it.
swh/indexer/tests/metadata_dictionary/test_npm.py
+
22
−
0
View file @
fa0b1de2
...
...
@@ -160,6 +160,28 @@ def test_index_content_metadata_npm(storage, obj_storage):
assert
expected_results
==
results
def
test_npm_null_list_item_normalization
():
package_json
=
b
"""
{
"
name
"
:
"
foo
"
,
"
keywords
"
: [
"
foo
"
,
null
],
"
homepage
"
: [
"
http://example.org/
"
,
null
]
}
"""
result
=
MAPPINGS
[
"
NpmMapping
"
]().
translate
(
package_json
)
assert
result
==
{
"
@context
"
:
"
https://doi.org/10.5063/schema/codemeta-2.0
"
,
"
name
"
:
"
foo
"
,
"
type
"
:
"
SoftwareSourceCode
"
,
"
url
"
:
"
http://example.org/
"
,
"
keywords
"
:
"
foo
"
,
}
def
test_npm_bugs_normalization
():
# valid dictionary
package_json
=
b
"""
{
...
...
This diff is collapsed.
Click to expand it.
Phabricator Migration user
@phabricator-migration
mentioned in merge request
!375 (closed)
·
2 years ago
mentioned in merge request
!375 (closed)
mentioned in merge request !375
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment