Skip to content

Commit

Permalink
Added loadmetadata parameter to CLAMClient
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Jan 30, 2017
1 parent fdb5629 commit 351a7d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions clam/common/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def donereadingupload(encoder):
pass

class CLAMClient:
def __init__(self, url, user=None, password=None, oauth=False, oauth_access_token=None,verify=None):
def __init__(self, url, user=None, password=None, oauth=False, oauth_access_token=None,verify=None, loadmetadata=False):
"""Initialise the CLAM client (does not actually connect yet)
* ``url`` - URL of the webservice
Expand All @@ -60,6 +60,7 @@ def __init__(self, url, user=None, password=None, oauth=False, oauth_access_toke
Set to the path to a CA_BUNDLE file or directory with certificates of trusted CAs, used certify by default
Can be set to False to skip verification (not recommended)
Follows the syntax of the requests library (http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification)
* ``loadmetadata`` - Automatically download and load all relevant metadata
"""

#self.http = httplib2.Http()
Expand All @@ -82,6 +83,7 @@ def __init__(self, url, user=None, password=None, oauth=False, oauth_access_toke
self.user = None
self.password = None
self.initauth()
self.loadmetadata = loadmetadata


def initauth(self):
Expand Down Expand Up @@ -184,7 +186,7 @@ def request(self, url='', method = 'GET', data = None, parse=True, encoding=None
def _parse(self, content):
"""Parses CLAM XML data and returns a ``CLAMData`` object. For internal use. Raises `ParameterError` exception on parameter errors."""
if content.find('<clam') != -1:
data = clam.common.data.CLAMData(content,self)
data = clam.common.data.CLAMData(content,self, loadmetadata=self.loadmetadata)
if data.errors:
error = data.parametererror()
if error:
Expand Down Expand Up @@ -524,8 +526,9 @@ def upload(self,project, inputtemplate, sourcefile, **kwargs):
"""Alias for ``addinputfile()``"""
return self.addinputfile(project, inputtemplate,sourcefile, **kwargs)

def download(self, project, filename, targetfilename, loadmetadata=False):
def download(self, project, filename, targetfilename, loadmetadata=None):
"""Download an output file"""
if loadmetadata is None: loadmetadata = self.loadmetadata
f = clam.common.data.CLAMOutputFile(self.url + project, filename, loadmetadata, self)
f.copy(targetfilename)

2 changes: 1 addition & 1 deletion clam/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import clam.common.util
import clam.common.viewers

VERSION = '2.1.7'
VERSION = '2.1.8'

#dirs for services shipped with CLAM itself
CONFIGDIR = os.path.abspath(os.path.dirname(__file__) + '/../config/')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def read(fname):

setup(
name = "CLAM",
version = "2.1.7", #also change in clam.common.data.VERSION
version = "2.1.8", #also change in clam.common.data.VERSION
author = "Maarten van Gompel",
author_email = "proycon@anaproy.nl",
description = ("Turns command-line NLP tools into fully-fledged RESTful webservices with an auto-generated web-interface for human end-users."),
Expand Down

0 comments on commit 351a7d6

Please sign in to comment.