Commit 43c7a3e7 authored by abuddenberg's avatar abuddenberg
Browse files

Add limited support for file operations

parent c56042ed
This diff is collapsed.
...@@ -107,6 +107,9 @@ class Figure(GcisObject): ...@@ -107,6 +107,9 @@ class Figure(GcisObject):
image_list = data.pop('images', None) image_list = data.pop('images', None)
self.images = [Image(image) for image in image_list] if image_list else [] 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 #Hack
self.identifier = self.identifier.replace('/figure/', '') if self.identifier not in ('', None) else '***ID MISSING***' self.identifier = self.identifier.replace('/figure/', '') if self.identifier not in ('', None) else '***ID MISSING***'
...@@ -468,3 +471,18 @@ class Webpage(Gcisbase): ...@@ -468,3 +471,18 @@ class Webpage(Gcisbase):
def __str__(self): def __str__(self):
return self.__repr__() 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__()
...@@ -746,4 +746,9 @@ class GcisClient(object): ...@@ -746,4 +746,9 @@ class GcisClient(object):
raise Exception('Lookup failed:\nQuery:{q}\nType:{t}\nResponse:\n{r}'.format(q=name, t=pub_type, r=resp.text)) raise Exception('Lookup failed:\nQuery:{q}\nType:{t}\nResponse:\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)
...@@ -19,7 +19,7 @@ class PyTest(TestCommand): ...@@ -19,7 +19,7 @@ class PyTest(TestCommand):
setup( setup(
name='GcisPyClient', name='GcisPyClient',
version='1.1.1', version='1.1.2',
author='Andrew Buddenberg', author='Andrew Buddenberg',
author_email='andrew.buddenberg@noaa.gov', author_email='andrew.buddenberg@noaa.gov',
packages=find_packages(), packages=find_packages(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment