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

Method upload_directory

webdav/client.py:466–487  ·  view source on GitHub ↗
(self, remote_path, local_path, progress=None)

Source from the content-addressed store, hash-verified

464 self.upload_file(local_path=local_path, remote_path=remote_path, progress=progress)
465
466 def upload_directory(self, remote_path, local_path, progress=None):
467
468 urn = Urn(remote_path, directory=True)
469
470 if not urn.is_dir():
471 raise OptionNotValid(name="remote_path", value=remote_path)
472
473 if not os.path.isdir(local_path):
474 raise OptionNotValid(name="local_path", value=local_path)
475
476 if not os.path.exists(local_path):
477 raise LocalResourceNotFound(local_path)
478
479 if self.check(urn.path()):
480 self.clean(urn.path())
481
482 self.mkdir(remote_path)
483
484 for resource_name in listdir(local_path):
485 _remote_path = "{parent}{name}".format(parent=urn.path(), name=resource_name)
486 _local_path = os.path.join(local_path, resource_name)
487 self.upload(local_path=_local_path, remote_path=_remote_path, progress=progress)
488
489 def upload_file(self, remote_path, local_path, progress=None):
490

Callers 1

uploadMethod · 0.95

Calls 10

is_dirMethod · 0.95
checkMethod · 0.95
pathMethod · 0.95
cleanMethod · 0.95
mkdirMethod · 0.95
uploadMethod · 0.95
UrnClass · 0.90
OptionNotValidClass · 0.85
listdirFunction · 0.85

Tested by

no test coverage detected