Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrew Buddenberg
gcis-py-client
Commits
43c7a3e7
Commit
43c7a3e7
authored
Apr 14, 2016
by
abuddenberg
Browse files
Add limited support for file operations
parent
c56042ed
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
bin/sync_surveys.py
View file @
43c7a3e7
This diff is collapsed.
Click to expand it.
gcis_clients/domain.py
View file @
43c7a3e7
...
...
@@ -107,6 +107,9 @@ class Figure(GcisObject):
image_list
=
data
.
pop
(
'images'
,
None
)
self
.
images
=
[
Image
(
image
)
for
image
in
image_list
]
if
image_list
else
[]
file_list
=
data
.
pop
(
'files'
,
None
)
self
.
files
=
[
File
(
f
)
for
f
in
file_list
]
if
file_list
else
[]
#Hack
self
.
identifier
=
self
.
identifier
.
replace
(
'/figure/'
,
''
)
if
self
.
identifier
not
in
(
''
,
None
)
else
'***ID MISSING***'
...
...
@@ -468,3 +471,18 @@ class Webpage(Gcisbase):
def
__str__
(
self
):
return
self
.
__repr__
()
class
File
(
Gcisbase
):
def
__init__
(
self
,
data
,
trans
=
()):
self
.
gcis_fields
=
[
'landing_page'
,
'sha1'
,
'url'
,
'thumbnail_href'
,
'uri'
,
'href'
,
'location'
,
'file'
,
'identifier'
,
'thumbnail'
,
'mime_type'
,
'size'
]
super
(
File
,
self
).
__init__
(
data
,
fields
=
self
.
gcis_fields
,
trans
=
trans
)
# def as_json(self, indent=0, omit_fields=('files', 'parents', 'contributors', 'references', 'cited_by')):
# return super(File, self).as_json(omit_fields=omit_fields)
def
__repr__
(
self
):
return
'<File id:{id} path:{p}>'
.
format
(
id
=
self
.
identifier
,
p
=
self
.
file
)
def
__str__
(
self
):
return
self
.
__repr__
()
gcis_clients/gcis_client.py
View file @
43c7a3e7
...
...
@@ -746,4 +746,9 @@ class GcisClient(object):
raise
Exception
(
'Lookup failed:
\n
Query:{q}
\n
Type:{t}
\n
Response:
\n
{r}'
.
format
(
q
=
name
,
t
=
pub_type
,
r
=
resp
.
text
))
@
http_resp
def
delete_file
(
self
,
file
):
url
=
'{b}/file/{id}'
.
format
(
b
=
self
.
base_url
,
id
=
file
.
identifier
)
return
self
.
s
.
delete
(
url
,
verify
=
False
)
setup.py
View file @
43c7a3e7
...
...
@@ -19,7 +19,7 @@ class PyTest(TestCommand):
setup
(
name
=
'GcisPyClient'
,
version
=
'1.1.
1
'
,
version
=
'1.1.
2
'
,
author
=
'Andrew Buddenberg'
,
author_email
=
'andrew.buddenberg@noaa.gov'
,
packages
=
find_packages
(),
...
...
Write
Preview
Supports
Markdown
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