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
d3b661db
Commit
d3b661db
authored
3 months ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
Avoid discarding whole nodes when their URI is invalid
parent
d096d44f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!533
Avoid discarding whole nodes when their URI is invalid
Pipeline
#12371
passed
3 months ago
Stage: external
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/indexer/bibtex.py
+6
-1
6 additions, 1 deletion
swh/indexer/bibtex.py
swh/indexer/tests/test_bibtex.py
+52
-0
52 additions, 0 deletions
swh/indexer/tests/test_bibtex.py
with
58 additions
and
1 deletion
swh/indexer/bibtex.py
+
6
−
1
View file @
d3b661db
...
...
@@ -77,7 +77,12 @@ def codemeta_to_bibtex(
identifiers
.
append
(
doc
[
"
identifier
"
])
doc
=
expand
(
doc
)
g
=
rdflib
.
Graph
().
parse
(
data
=
json
.
dumps
(
doc
),
format
=
"
json-ld
"
)
g
=
rdflib
.
Graph
().
parse
(
data
=
json
.
dumps
(
doc
),
format
=
"
json-ld
"
,
# replace invalid URIs with blank node ids, instead of discarding whole nodes:
generalized_rdf
=
True
,
)
persons
:
Dict
[
str
,
List
[
Person
]]
=
collections
.
defaultdict
(
list
)
fields
:
Dict
[
str
,
Any
]
=
{}
...
...
This diff is collapsed.
Click to expand it.
swh/indexer/tests/test_bibtex.py
+
52
−
0
View file @
d3b661db
...
...
@@ -276,6 +276,58 @@ def test_affiliation():
)
def
test_author_id
():
assert
codemeta_to_bibtex
(
{
"
@context
"
:
"
https://doi.org/10.5063/schema/codemeta-2.0
"
,
"
author
"
:
{
"
name
"
:
"
Jane Doe
"
,
"
id
"
:
"
https://orcid.org/0000-0002-2771-9344
"
,
},
"
name
"
:
"
Example Software
"
,
"
url
"
:
"
http://example.org/
"
,
"
datePublished
"
:
"
2023-10-10
"
,
}
)
==
textwrap
.
dedent
(
"""
\
@software{REPLACEME,
author =
"
Doe, Jane
"
,
date =
"
2023-10-10
"
,
year =
"
2023
"
,
month = oct,
title =
"
Example Software
"
,
url =
"
http://example.org/
"
}
"""
)
def
test_author_invalid_id
():
assert
codemeta_to_bibtex
(
{
"
@context
"
:
"
https://doi.org/10.5063/schema/codemeta-2.0
"
,
"
author
"
:
{
"
name
"
:
"
Jane Doe
"
,
"
id
"
:
"
https://orcid.org/ 0000-0002-2771-9344
"
,
},
"
name
"
:
"
Example Software
"
,
"
url
"
:
"
http://example.org/
"
,
"
datePublished
"
:
"
2023-10-10
"
,
}
)
==
textwrap
.
dedent
(
"""
\
@software{REPLACEME,
author =
"
Doe, Jane
"
,
date =
"
2023-10-10
"
,
year =
"
2023
"
,
month = oct,
title =
"
Example Software
"
,
url =
"
http://example.org/
"
}
"""
)
def
test_invalid_date
():
assert
codemeta_to_bibtex
(
{
...
...
This diff is collapsed.
Click to expand it.
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