MCPcopy Create free account
hub / github.com/CloudPolis/webdav-client-python / move

Method move

webdav/client.py:589–624  ·  view source on GitHub ↗
(self, remote_path_from, remote_path_to)

Source from the content-addressed store, hash-verified

587 raise NotConnection(self.webdav.hostname)
588
589 def move(self, remote_path_from, remote_path_to):
590
591 def header(remote_path_to):
592
593 path = Urn(remote_path_to).path()
594 destination = "{root}{path}".format(root=self.webdav.root, path=path)
595 header_item = "Destination: {destination}".format(destination=destination)
596 header = self.get_header('move')
597 header.append(header_item)
598 return header
599
600 try:
601 urn_from = Urn(remote_path_from)
602
603 if not self.check(urn_from.path()):
604 raise RemoteResourceNotFound(urn_from.path())
605
606 urn_to = Urn(remote_path_to)
607
608 if not self.check(urn_to.parent()):
609 raise RemoteParentNotFound(urn_to.path())
610
611 url = {'hostname': self.webdav.hostname, 'root': self.webdav.root, 'path': urn_from.quote()}
612 options = {
613 'URL': "{hostname}{root}{path}".format(**url),
614 'CUSTOMREQUEST': Client.requests['move'],
615 'HTTPHEADER': header(remote_path_to)
616 }
617
618 request = self.Request(options=options)
619
620 request.perform()
621 request.close()
622
623 except pycurl.error:
624 raise NotConnection(self.webdav.hostname)
625
626 def clean(self, remote_path):
627

Callers 2

renameMethod · 0.45
moveMethod · 0.45

Calls 9

checkMethod · 0.95
pathMethod · 0.95
parentMethod · 0.95
quoteMethod · 0.95
RequestMethod · 0.95
UrnClass · 0.90
NotConnectionClass · 0.85

Tested by

no test coverage detected