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

Method set_property

webdav/client.py:924–962  ·  view source on GitHub ↗
(self, remote_path, option)

Source from the content-addressed store, hash-verified

922 raise NotConnection(self.webdav.hostname)
923
924 def set_property(self, remote_path, option):
925
926 def data(option):
927
928 root_node = etree.Element("propertyupdate", xmlns="DAV:")
929 root_node.set('xmlns:u', option.get('namespace', ""))
930 set_node = etree.SubElement(root_node, "set")
931 prop_node = etree.SubElement(set_node, "prop")
932 opt_node = etree.SubElement(prop_node, "{namespace}:{name}".format(namespace='u', name=option['name']))
933 opt_node.text = option.get('value', "")
934
935 tree = etree.ElementTree(root_node)
936
937 buff = BytesIO()
938 tree.write(buff)
939
940 return buff.getvalue()
941
942 try:
943 urn = Urn(remote_path)
944
945 if not self.check(urn.path()):
946 raise RemoteResourceNotFound(urn.path())
947
948 url = {'hostname': self.webdav.hostname, 'root': self.webdav.root, 'path': urn.quote()}
949 options = {
950 'URL': "{hostname}{root}{path}".format(**url),
951 'CUSTOMREQUEST': Client.requests['set_metadata'],
952 'HTTPHEADER': self.get_header('get_metadata'),
953 'POSTFIELDS': data(option)
954 }
955
956 request = self.Request(options=options)
957
958 request.perform()
959 request.close()
960
961 except pycurl.error:
962 raise NotConnection(self.webdav.hostname)
963
964 def push(self, remote_directory, local_directory):
965

Callers 1

propertyMethod · 0.80

Calls 8

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

Tested by

no test coverage detected