From dad6078cb85a87511613233e7689e7cdafb35c6d Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Thu, 19 Dec 2019 12:37:15 +0100 Subject: [PATCH] Set a default path in the URL for ICAT and IDS respectively. Close #63. --- CHANGES | 4 ++++ icat/client.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 7619f467..5c0cbe61 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,10 @@ * Version 0.17.0 (not yet published) +** New features + + + #63: Set a default path in the URL for ICAT and IDS respectively. + ** Incompatible changes and deprecations + Deprecate support for Python 2. diff --git a/icat/client.py b/icat/client.py index 38265ebc..b440ba4f 100644 --- a/icat/client.py +++ b/icat/client.py @@ -10,6 +10,7 @@ import logging from distutils.version import StrictVersion as Version import atexit +import urlparse import suds import suds.client @@ -140,6 +141,13 @@ study = icat.entities.Study410, user = icat.entities.User410 ) +def _complete_url(url, default_path="/ICATService/ICAT?wsdl"): + if not url: + return url + o = urlparse.urlparse(url) + if o.path or o.query: + return url + return "%s://%s%s" % (o.scheme, o.netloc, default_path) class Client(suds.client.Client): @@ -197,10 +205,10 @@ def __init__(self, url, **kwargs): :see: :class:`suds.options.Options` for the keyword arguments. """ - self.url = url + self.url = _complete_url(url) self.kwargs = dict(kwargs) - idsurl = kwargs.pop('idsurl', None) + idsurl = _complete_url(kwargs.pop('idsurl', None), default_path="/ids") sslverify = kwargs.pop('checkCert', True) cafile = kwargs.pop('caFile', None)