class Upload(object): def __init__(self, baseUrl, log, userAgent="Meresco-Fetch Harvester"): if not baseUrl: self._sruUpdateClient = _Ignore() else: _, netloc, path, _, _ = urlsplit(baseUrl) host, port = netloc.split(':', 1) if ':' in netloc else (netloc, 80) self._sruUpdateClient = SruUpdateClient( host=host, port=int(port), path=path, userAgent=userAgent, synchronous=True) self._log = log self._log.write("Uploading to: %s\n" % repr(baseUrl)) def uploadRecord(self, identifier, data): self._upload(identifier, data) self._log.write("Uploaded: %s\n" % identifier) def deleteRecord(self, identifier): self._delete(identifier) self._log.write("Deleted: %s\n" % identifier) def _upload(self, identifier, data): consume(self._sruUpdateClient.add(identifier=identifier, data=data)) def _delete(self, identifier): consume(self._sruUpdateClient.delete(identifier=identifier))
def __init__(self, baseUrl, log, userAgent="Meresco-Fetch Harvester"): if not baseUrl: self._sruUpdateClient = _Ignore() else: _, netloc, path, _, _ = urlsplit(baseUrl) host, port = netloc.split(':', 1) if ':' in netloc else (netloc, 80) self._sruUpdateClient = SruUpdateClient( host=host, port=int(port), path=path, userAgent=userAgent, synchronous=True) self._log = log self._log.write("Uploading to: %s\n" % repr(baseUrl))