Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
eossr
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Admin message
Gitlab has been updated. More info
here
.
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ESCAPE2020
WP3
eossr
Commits
89470238
Commit
89470238
authored
3 years ago
by
Vuillaume
Committed by
Enrique Garcia
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix fetch user entries
parent
b86d7b61
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!70
Fix fetch user entries
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eossr/api/zenodo/__init__.py
+13
-5
13 additions, 5 deletions
eossr/api/zenodo/__init__.py
eossr/scripts/eossr_upload_repository.py
+4
-2
4 additions, 2 deletions
eossr/scripts/eossr_upload_repository.py
with
17 additions
and
7 deletions
eossr/api/zenodo/__init__.py
+
13
−
5
View file @
89470238
...
...
@@ -93,8 +93,9 @@ class ZenodoAPI:
:return: request.get method
"""
url
=
f
"
{
self
.
api_url
}
/deposit/depositions
"
return
requests
.
get
(
url
,
params
=
self
.
parameters
)
answer
=
requests
.
get
(
url
,
params
=
self
.
parameters
)
http_status
.
ZenodoHTTPStatus
(
answer
.
status_code
,
answer
.
json
())
return
answer
def
create_new_entry
(
self
):
"""
...
...
@@ -126,7 +127,9 @@ class ZenodoAPI:
# To fetch any other entry, already published, use:
url
=
f
"
{
self
.
api_url
}
/records/
{
entry_id
}
"
return
requests
.
get
(
url
,
params
=
self
.
parameters
)
req
=
requests
.
get
(
url
,
params
=
self
.
parameters
)
http_status
.
ZenodoHTTPStatus
(
req
.
status_code
,
req
.
json
())
return
req
def
upload_file_entry
(
self
,
entry_id
,
name_file
,
path_file
):
"""
...
...
@@ -523,7 +526,7 @@ class ZenodoAPI:
def
get_user_records
(
self
):
"""
Finds all the records associated with a user (defined by the zenodo token)
"""
request
=
self
.
fetch_user_entries
()
return
[
Record
(
hit
)
for
hit
in
request
.
json
()]
return
[
Record
(
hit
)
for
hit
in
request
.
json
()
if
hit
[
'
state
'
]
==
'
done
'
]
def
find_similar_records
(
self
,
record
):
"""
...
...
@@ -562,6 +565,11 @@ class Record:
for
k
in
[
'
id
'
,
'
metadata
'
]:
if
k
not
in
data
.
keys
():
raise
ValueError
(
f
"
key
{
k
}
not present in data
"
)
# list of keys mandatory to create a Zenodo entry.
# Other keys are either optional, or can be hidden in case of Closed Access entries.
for
meta_key
in
[
'
title
'
,
'
description
'
,
'
creators
'
,
'
doi
'
,
'
publication_date
'
,
'
access_right
'
]:
if
meta_key
not
in
data
[
'
metadata
'
].
keys
():
raise
ValueError
(
f
"
Mandatory key
{
meta_key
}
not in data[
'
metadata
'
]
"
)
self
.
data
=
data
def
__str__
(
self
):
...
...
@@ -594,7 +602,7 @@ class Record:
return
self
.
data
[
'
metadata
'
][
'
relations
'
][
'
version
'
][
0
][
'
last_child
'
][
'
pid_value
'
]
def
get_last_version
(
self
):
if
self
.
data
[
'
metadata
'
][
'
relations
'
][
'
version
'
][
0
][
'
is_last
'
]:
if
'
relations
'
not
in
self
.
data
[
'
metadata
'
]
or
self
.
data
[
'
metadata
'
][
'
relations
'
][
'
version
'
][
0
][
'
is_last
'
]:
return
self
else
:
record_id
=
self
.
last_version_id
...
...
This diff is collapsed.
Click to expand it.
eossr/scripts/eossr_upload_repository.py
+
4
−
2
View file @
89470238
...
...
@@ -7,6 +7,7 @@ import argparse
import
json
from
pathlib
import
Path
from
distutils.util
import
strtobool
from
copy
import
deepcopy
from
eossr.api.zenodo
import
ZenodoAPI
,
Record
,
SimilarRecordError
from
eossr.metadata.codemeta2zenodo
import
converter
from
eossr.utils
import
zip_repository
...
...
@@ -64,11 +65,12 @@ def upload(zenodo_token, sandbox_flag, upload_directory, record_id=None, zip_roo
else
:
raise
FileNotFoundError
(
"
No metadata provided
"
)
metadata_for_check
=
{
'
metadata
'
:
metadata
}
metadata_for_check
=
{
'
metadata
'
:
deepcopy
(
metadata
)
}
metadata_for_check
[
'
id
'
]
=
1
# fake id to create fake record
metadata_for_check
[
'
metadata
'
][
'
doi
'
]
=
1
# fake doi to create fake record
record
=
Record
(
metadata_for_check
)
# Searches for similar records
#
#
Searches for similar records
similar_records
=
zenodo
.
find_similar_records
(
record
)
if
similar_records
and
not
force_new_record
and
not
record_id
:
raise
SimilarRecordError
(
...
...
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