(self, remote_path)
| 740 | raise NotConnection(self.webdav.hostname) |
| 741 | |
| 742 | def info(self, remote_path): |
| 743 | |
| 744 | def parse(response, path): |
| 745 | |
| 746 | try: |
| 747 | response_str = response.getvalue() |
| 748 | tree = etree.fromstring(response_str) |
| 749 | |
| 750 | find_attributes = { |
| 751 | 'created': ".//{DAV:}creationdate", |
| 752 | 'name': ".//{DAV:}displayname", |
| 753 | 'size': ".//{DAV:}getcontentlength", |
| 754 | 'modified': ".//{DAV:}getlastmodified" |
| 755 | } |
| 756 | |
| 757 | resps = tree.findall("{DAV:}response") |
| 758 | |
| 759 | for resp in resps: |
| 760 | href = resp.findtext("{DAV:}href") |
| 761 | urn = unquote(href) |
| 762 | |
| 763 | if path[-1] == Urn.separate: |
| 764 | if not path == urn: |
| 765 | continue |
| 766 | else: |
| 767 | path_with_sep = "{path}{sep}".format(path=path, sep=Urn.separate) |
| 768 | if not path == urn and not path_with_sep == urn: |
| 769 | continue |
| 770 | |
| 771 | info = dict() |
| 772 | for (name, value) in find_attributes.items(): |
| 773 | info[name] = resp.findtext(value) |
| 774 | return info |
| 775 | |
| 776 | raise RemoteResourceNotFound(path) |
| 777 | except etree.XMLSyntaxError: |
| 778 | raise MethodNotSupported(name="info", server=self.webdav.hostname) |
| 779 | |
| 780 | try: |
| 781 | urn = Urn(remote_path) |
| 782 | response = BytesIO() |
| 783 | |
| 784 | if not self.check(urn.path()) and not self.check(Urn(remote_path, directory=True).path()): |
| 785 | raise RemoteResourceNotFound(remote_path) |
| 786 | |
| 787 | url = {'hostname': self.webdav.hostname, 'root': self.webdav.root, 'path': urn.quote()} |
| 788 | options = { |
| 789 | 'URL': "{hostname}{root}{path}".format(**url), |
| 790 | 'CUSTOMREQUEST': Client.requests['info'], |
| 791 | 'HTTPHEADER': self.get_header('info'), |
| 792 | 'WRITEDATA': response, |
| 793 | 'NOBODY': 0 |
| 794 | } |
| 795 | |
| 796 | request = self.Request(options=options) |
| 797 | |
| 798 | request.perform() |
| 799 | request.close() |
no test coverage detected