Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
1cbc7043
Commit
1cbc7043
authored
Jun 17, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
start class to perform request with TogoWS
parent
a122ba2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
web/metagenedb/common/__init__.py
0 → 100644
View file @
1cbc7043
web/metagenedb/common/api.py
0 → 100644
View file @
1cbc7043
from
abc
import
abstractmethod
,
ABC
import
requests
class
TogoWS
(
ABC
):
BASE_URL
=
'http://togows.org'
@
abstractmethod
def
get
(
self
,
entry_id
):
pass
class
TogoWSEntry
(
TogoWS
):
TYPE
=
'entry'
def
__init__
(
self
,
database
,
format
=
'json'
):
self
.
database
=
database
self
.
format
=
format
def
get
(
self
,
entry_id
):
full_url
=
f
"
{
self
.
BASE_URL
}
/
{
self
.
TYPE
}
/
{
self
.
database
}
/
{
entry_id
}
.
{
self
.
format
}
"
response
=
requests
.
get
(
full_url
)
response
.
raise_for_status
()
return
response
.
json
()
def
get_field
(
self
,
entry_id
,
field
):
full_url
=
f
"
{
self
.
BASE_URL
}
/
{
self
.
TYPE
}
/
{
self
.
database
}
/
{
entry_id
}
.
{
field
}
.
{
self
.
format
}
"
response
=
requests
.
get
(
full_url
)
response
.
raise_for_status
()
return
response
.
json
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment