Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Z
ZenodoCI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Show more breadcrumbs
Enrique Garcia
ZenodoCI
Commits
b0814dc5
Commit
b0814dc5
authored
3 years ago
by
Enrique
Browse files
Options
Downloads
Patches
Plain Diff
update fetch methods
parent
189be17c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zenodoci/zenodoapi.py
+16
-3
16 additions, 3 deletions
zenodoci/zenodoapi.py
with
16 additions
and
3 deletions
zenodoci/zenodoapi.py
+
16
−
3
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
:
...
...
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