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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ESCAPE2020
WP3
eossr
Commits
9037b591
Commit
9037b591
authored
3 years ago
by
Vuillaume
Committed by
Enrique Garcia
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
simplify record representation, prettier decription in print_info and method to write zenodo json
parent
3526eae7
No related branches found
No related tags found
1 merge request
!48
simplify record representation, prettier decription in print_info and method to write zenodo json
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
eossr/api/zenodo/__init__.py
+13
-5
13 additions, 5 deletions
eossr/api/zenodo/__init__.py
eossr/api/zenodo/tests/test_zenodo.py
+7
-0
7 additions, 0 deletions
eossr/api/zenodo/tests/test_zenodo.py
setup.py
+2
-1
2 additions, 1 deletion
setup.py
with
22 additions
and
6 deletions
eossr/api/zenodo/__init__.py
+
13
−
5
View file @
9037b591
...
...
@@ -10,6 +10,7 @@ from urllib.parse import urlencode
from
urllib.request
import
urlopen
from
...metadata.codemeta2zenodo
import
parse_codemeta_and_write_zenodo_metadata_file
from
.
import
http_status
from
bs4
import
BeautifulSoup
__all__
=
[
'
ZenodoAPI
'
,
...
...
@@ -432,7 +433,14 @@ class Record:
return
f
"
Record #
{
self
.
id
}
:
{
self
.
title
}
"
def
__repr__
(
self
):
return
json
.
dumps
(
self
.
data
,
indent
=
4
,
sort_keys
=
True
)
return
f
"
Record(
{
self
.
id
}
)
"
def
write_zenodo
(
self
,
filename
=
'
.zenodo.json
'
,
overwrite
=
False
):
if
Path
(
filename
).
exists
()
and
not
overwrite
:
raise
FileExistsError
(
f
"
The file
{
filename
}
exists. Use overwrite.
"
)
else
:
with
open
(
filename
,
'
w
'
)
as
file
:
json
.
dump
(
self
.
data
,
file
)
@property
def
id
(
self
):
...
...
@@ -444,7 +452,7 @@ class Record:
def
print_info
(
self
):
metadata
=
self
.
data
[
'
metadata
'
]
descrp
=
metadata
[
'
description
'
]
descrp
=
BeautifulSoup
(
metadata
[
'
description
'
]
).
text
print
(
f
"
=== Record #
{
self
.
id
}
===
"
)
print
(
f
"
Title:
{
self
.
title
}
===
"
)
print
(
f
"
DOI:
{
self
.
data
[
'
doi
'
]
}
"
)
...
...
@@ -468,9 +476,9 @@ class Record:
@property
def
doi
(
self
):
if
not
'
concept
doi
'
in
self
.
data
:
raise
KeyError
(
f
"
Record
{
self
.
id
}
does not have a
concept
doi
"
)
return
self
.
data
[
'
concept
doi
'
]
if
not
'
doi
'
in
self
.
data
:
raise
KeyError
(
f
"
Record
{
self
.
id
}
does not have a doi
"
)
return
self
.
data
[
'
doi
'
]
def
get_mybinder_url
(
self
):
binder_zenodo_url
=
'
https://mybinder.org/v2/zenodo/
'
...
...
This diff is collapsed.
Click to expand it.
eossr/api/zenodo/tests/test_zenodo.py
+
7
−
0
View file @
9037b591
...
...
@@ -177,3 +177,10 @@ def test_record(test_get_record_4923992):
def
test_get_record_sandbox
():
record
=
get_record
(
520735
,
sandbox
=
True
)
assert
record
.
data
[
'
doi
'
]
==
'
10.5072/zenodo.520735
'
def
test_write_record_zenodo
(
test_get_record_4923992
,
tmpdir
):
record
=
test_get_record_4923992
record
.
write_zenodo
(
filename
=
tmpdir
/
'
.zenodo.json
'
)
with
open
(
tmpdir
/
'
.zenodo.json
'
)
as
file
:
json_dict
=
json
.
load
(
file
)
assert
json_dict
[
'
conceptdoi
'
]
==
'
10.5281/zenodo.3572654
'
This diff is collapsed.
Click to expand it.
setup.py
+
2
−
1
View file @
9037b591
...
...
@@ -23,7 +23,8 @@ setup(
version
=
get_property
(
'
__version__
'
,
'
eossr
'
),
description
=
"
ESCAPE OSSR library
"
,
install_requires
=
[
"
requests
"
"
requests
"
,
"
bs4
"
,
],
packages
=
find_packages
(),
scripts
=
[
'
eossr/scripts/parse_last_release_git.sh
'
],
...
...
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