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

Method list

webdav/client.py:184–225  ·  view source on GitHub ↗
(self, remote_path=root)

Source from the content-addressed store, hash-verified

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

Callers 3

download_directoryMethod · 0.95
pushMethod · 0.95
pullMethod · 0.95

Calls 9

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

Tested by

no test coverage detected