Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
ESCAPE2020
WP3
ZenodoCI
Commits
b0814dc5
Commit
b0814dc5
authored
May 25, 2021
by
Enrique Garcia
Browse files
update fetch methods
parent
189be17c
Pipeline
#120611
passed with stages
in 59 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
zenodoci/zenodoapi.py
zenodoci/zenodoapi.py
+16
-3
No files found.
zenodoci/zenodoapi.py
View file @
b0814dc5
...
...
@@ -21,6 +21,7 @@ class ZenodoAPI:
- Fetches a user's published entries,
- Creates a new deposit,
- Fetches any published record,
- Creates a new version of an existing deposit,
- Uploads files to a specific Zenodo entry,
- Erases a non-published entry / new version draft,
...
...
@@ -28,6 +29,9 @@ class ZenodoAPI:
new_version files),
- Uploads information to the entry (Zenodo compulsory deposit information),
- Publishes an entry
- Find all the published community entries
* per title
* per entry_id
:param access_token: str
...
...
@@ -87,7 +91,11 @@ class ZenodoAPI:
:return: request.get method
"""
url
=
f
"
{
self
.
zenodo_api_url
}
/deposit/depositions/
{
entry_id
}
"
# In case of entries created by oneself, and maybe not published yet, the method to fetch them is
# request.get('api/deposit/deposition/{entry_id}')
# To fetch any other entry not belonging/published to yourself/user
url
=
f
"
{
self
.
zenodo_api_url
}
/records/
{
entry_id
}
"
return
requests
.
get
(
url
,
params
=
self
.
parameters
)
def
upload_file_entry
(
self
,
entry_id
,
name_file
,
path_file
):
...
...
@@ -135,7 +143,11 @@ class ZenodoAPI:
url
=
f
"
{
self
.
zenodo_api_url
}
/deposit/depositions/
{
entry_id
}
"
headers
=
{
"Content-Type"
:
"application/json"
}
return
requests
.
put
(
url
,
data
=
json
.
dumps
(
json_metadata
),
# The metadata field is already created, just need to be updated.
# Thus the root 'metadata' key need to be kept, to indicate the field to be updated.
data
=
{
"metadata"
:
json_metadata
}
return
requests
.
put
(
url
,
data
=
json
.
dumps
(
data
),
headers
=
headers
,
params
=
self
.
parameters
)
def
erase_entry
(
self
,
entry_id
):
...
...
@@ -366,7 +378,8 @@ class ZenodoAPI:
print
(
" * Update metadata status OK !"
)
pprint
.
pprint
(
metadata_entry
)
else
:
print
(
" ! ERROR while testing update of metadata
\n
"
,
update_metadata
.
json
())
print
(
" ! ERROR while testing update of metadata
\n
"
,
update_metadata
.
json
(),
"
\n
"
,
metadata_entry
)
print
(
" ! Erasing dummy test entry...
\n
"
)
erase_error
=
self
.
erase_entry
(
test_entry_id
)
if
erase_error
.
status_code
!=
204
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment