Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
3ed9de45
Commit
3ed9de45
authored
1 year ago
by
fima
Browse files
Options
Downloads
Plain Diff
Merge branch 'api_bug' into 'main'
Fix API bug See merge request
!53
parents
c00db7f0
b48c950f
No related branches found
No related tags found
1 merge request
!53
Fix API bug
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/utils/doi.py
+22
-7
22 additions, 7 deletions
qim3d/utils/doi.py
with
22 additions
and
7 deletions
qim3d/utils/doi.py
+
22
−
7
View file @
3ed9de45
...
@@ -56,13 +56,6 @@ def get_bibtex(doi):
...
@@ -56,13 +56,6 @@ def get_bibtex(doi):
return
_log_and_get_text
(
doi
,
header
)
return
_log_and_get_text
(
doi
,
header
)
def
get_reference
(
doi
):
"""
Generates basic reference from doi
"""
header
=
{
"
Accept
"
:
"
text/bibliography
"
}
return
_log_and_get_text
(
doi
,
header
)
def
cusom_header
(
doi
,
header
):
def
cusom_header
(
doi
,
header
):
"""
Allows a custom header to be passed
"""
Allows a custom header to be passed
...
@@ -80,4 +73,26 @@ def get_metadata(doi):
...
@@ -80,4 +73,26 @@ def get_metadata(doi):
response
=
_make_request
(
doi
,
header
)
response
=
_make_request
(
doi
,
header
)
metadata
=
json
.
loads
(
response
.
text
)
metadata
=
json
.
loads
(
response
.
text
)
return
metadata
return
metadata
def
get_reference
(
doi
):
"""
Generates a metadata dictionary from doi and use it to build a reference string
"""
metadata
=
get_metadata
(
doi
)
reference_string
=
build_reference_string
(
metadata
)
return
reference_string
def
build_reference_string
(
metadata
):
"""
Generates a reference string from metadata
"""
authors
=
"
,
"
.
join
([
f
"
{
author
[
'
family
'
]
}
{
author
[
'
given
'
]
}
"
for
author
in
metadata
[
'
author
'
]])
year
=
metadata
[
'
issued
'
][
'
date-parts
'
][
0
][
0
]
title
=
metadata
[
'
title
'
]
publisher
=
metadata
[
'
publisher
'
]
url
=
metadata
[
'
URL
'
]
doi
=
metadata
[
'
DOI
'
]
reference_string
=
f
"
{
authors
}
(
{
year
}
).
{
title
}
.
{
publisher
}
(
{
url
}
). DOI:
{
doi
}
"
return
reference_string
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