Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymoondb
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alessandro Frigeri
pymoondb
Commits
800e85dd
Commit
800e85dd
authored
6 years ago
by
Alessandro Frigeri
Browse files
Options
Downloads
Patches
Plain Diff
test
parent
782b86c2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
moondb.py
+87
-0
87 additions, 0 deletions
moondb.py
with
87 additions
and
0 deletions
moondb.py
0 → 100755
+
87
−
0
View file @
800e85dd
#!/usr/bin/python
#
# Alessandro Frigeri 2019
#
# MoonDB Python module
# https://realpython.com/api-integration-in-python/
import
requests
import
json
def
_url
(
path
):
return
"
http://api.moondb.org
"
+
path
def
get_specimen
():
pass
def
get_specimentype
():
pass
def
get_mission
():
pass
def
_check_resp
(
resp
):
if
resp
.
status_code
!=
200
:
#raise ApiError('Cannot fetch all objects: {}'.format(resp.status_code))
pass
def
_json_object_hook
(
d
):
return
namedtuple
(
'
X
'
,
d
.
keys
())(
*
d
.
values
())
def
json2obj
(
data
):
return
json
.
loads
(
data
,
object_hook
=
_json_object_hook
)
def
get_analytes
():
analytes
=
[]
resp
=
requests
.
get
(
_url
(
'
/cv/analytes/
'
))
_check_resp
(
resp
)
for
m_item
in
resp
.
json
()[
'
result
'
]:
analytes
.
append
(
Analyte
(
m_item
[
'
name
'
]
))
return
analytes
def
get_missions
():
missions
=
[]
resp
=
requests
.
get
(
_url
(
'
/authorities/missions/
'
))
_check_resp
(
resp
)
for
m_item
in
resp
.
json
()[
'
result
'
]:
missions
.
append
(
Mission
(
m_item
[
'
name
'
]
))
print
(
m_item
)
this_m
=
json
.
loads
(
"
{
'
name
'
:
'
Apollo 11
'
}
"
)
return
missions
def
get_missions2
():
resp
=
requests
.
get
(
_url
(
'
/authorities/missions/
'
))
#m2 = json.loads(resp)
print
(
resp
)
return
resp
.
json
()[
'
result
'
]
def
get_landmark
():
pass
def
get_samplingtechnique
():
pass
class
Filter
:
def
__init__
(
self
):
self
.
mission
=
None
class
Mission
:
def
__init__
(
self
,
name
):
self
.
name
=
name
class
AnalysisMethos
:
def
__init__
(
self
,
code
,
name
):
self
.
name
=
name
self
.
code
=
code
class
Analyte
:
def
__init__
(
self
,
name
):
self
.
name
=
name
if
__name__
==
"
__main__
"
:
m
=
get_missions
()
print
m
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