(self, remote_path, option)
| 873 | return Resource(self, urn.path()) |
| 874 | |
| 875 | def get_property(self, remote_path, option): |
| 876 | |
| 877 | def parse(response, option): |
| 878 | |
| 879 | response_str = response.getvalue() |
| 880 | tree = etree.fromstring(response_str) |
| 881 | xpath = "{xpath_prefix}{xpath_exp}".format(xpath_prefix=".//", xpath_exp=option['name']) |
| 882 | return tree.findtext(xpath) |
| 883 | |
| 884 | def data(option): |
| 885 | |
| 886 | root = etree.Element("propfind", xmlns="DAV:") |
| 887 | prop = etree.SubElement(root, "prop") |
| 888 | etree.SubElement(prop, option.get('name', ""), xmlns=option.get('namespace', "")) |
| 889 | tree = etree.ElementTree(root) |
| 890 | |
| 891 | buff = BytesIO() |
| 892 | |
| 893 | tree.write(buff) |
| 894 | return buff.getvalue() |
| 895 | |
| 896 | try: |
| 897 | urn = Urn(remote_path) |
| 898 | |
| 899 | if not self.check(urn.path()): |
| 900 | raise RemoteResourceNotFound(urn.path()) |
| 901 | |
| 902 | response = BytesIO() |
| 903 | |
| 904 | url = {'hostname': self.webdav.hostname, 'root': self.webdav.root, 'path': urn.quote()} |
| 905 | options = { |
| 906 | 'URL': "{hostname}{root}{path}".format(**url), |
| 907 | 'CUSTOMREQUEST': Client.requests['get_metadata'], |
| 908 | 'HTTPHEADER': self.get_header('get_metadata'), |
| 909 | 'POSTFIELDS': data(option), |
| 910 | 'WRITEDATA': response, |
| 911 | 'NOBODY': 0 |
| 912 | } |
| 913 | |
| 914 | request = self.Request(options=options) |
| 915 | |
| 916 | request.perform() |
| 917 | request.close() |
| 918 | |
| 919 | return parse(response, option) |
| 920 | |
| 921 | except pycurl.error: |
| 922 | raise NotConnection(self.webdav.hostname) |
| 923 | |
| 924 | def set_property(self, remote_path, option): |
| 925 |
no test coverage detected