(self, remote_path=root)
| 182 | return curl |
| 183 | |
| 184 | def list(self, remote_path=root): |
| 185 | |
| 186 | def parse(response): |
| 187 | |
| 188 | try: |
| 189 | response_str = response.getvalue() |
| 190 | tree = etree.fromstring(response_str) |
| 191 | hrees = [unquote(hree.text) for hree in tree.findall(".//{DAV:}href")] |
| 192 | return [Urn(hree) for hree in hrees] |
| 193 | except etree.XMLSyntaxError: |
| 194 | return list() |
| 195 | |
| 196 | try: |
| 197 | directory_urn = Urn(remote_path, directory=True) |
| 198 | |
| 199 | if directory_urn.path() != Client.root: |
| 200 | if not self.check(directory_urn.path()): |
| 201 | raise RemoteResourceNotFound(directory_urn.path()) |
| 202 | |
| 203 | response = BytesIO() |
| 204 | |
| 205 | url = {'hostname': self.webdav.hostname, 'root': self.webdav.root, 'path': directory_urn.quote()} |
| 206 | options = { |
| 207 | 'URL': "{hostname}{root}{path}".format(**url), |
| 208 | 'CUSTOMREQUEST': Client.requests['list'], |
| 209 | 'HTTPHEADER': self.get_header('list'), |
| 210 | 'WRITEDATA': response, |
| 211 | 'NOBODY': 0 |
| 212 | } |
| 213 | |
| 214 | request = self.Request(options=options) |
| 215 | |
| 216 | request.perform() |
| 217 | request.close() |
| 218 | |
| 219 | urns = parse(response) |
| 220 | |
| 221 | path = "{root}{path}".format(root=self.webdav.root, path=directory_urn.path()) |
| 222 | return [urn.filename() for urn in urns if urn.path() != path and urn.path() != path[:-1]] |
| 223 | |
| 224 | except pycurl.error: |
| 225 | raise NotConnection(self.webdav.hostname) |
| 226 | |
| 227 | def free(self): |
| 228 |
no test coverage detected