diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000..d6108e4 --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,16 @@ +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: python-webdav + description: python-webdav is a client webdav library for Python + annotations: + business-unit: EverHealth + github.com/project-slug: drchrono/python-webdav + product: DRC +spec: + type: service + lifecycle: production + owner: EverHealth + implementation: + languages: + - Python diff --git a/python_webdav/connection.py b/python_webdav/connection.py index 6bfd927..b86ffb3 100644 --- a/python_webdav/connection.py +++ b/python_webdav/connection.py @@ -109,6 +109,29 @@ def send_get(self, path, headers=None, callback=False): except requests.ConnectionError: raise + def send_streaming_get(self, path, headers=None, chunk_size=102400): + """ Send a streaming GET request, useful for uploading large files + It returns iterator over the content. + :see http://docs.python-requests.org/en/latest/api/#requests.Response.iter_content + + :param path: The path (without host) to the resource to get + :type path: String + + :param headers: Additional headers for the request should be added here + :type headers: Dict + + :param chunk_size: The size of the chunk to be returned by the + iterator, default is 100K + :type chunk_size: Int + """ + if not headers: + headers = {} + + uri = "%s/%s" % (self.host.rstrip('/'), path.lstrip('/')) + resp = self.httpcon.get(uri, headers=headers, stream=True) + + return resp, resp.iter_content(chunk_size=chunk_size) + def send_put(self, path, body, headers=None): """ This PUT request will put data files onto a webdav server. However, please note that due to the way in which httplib2 sends diff --git a/python_webdav/parse.py b/python_webdav/parse.py index 20c7208..aeb329e 100644 --- a/python_webdav/parse.py +++ b/python_webdav/parse.py @@ -4,7 +4,7 @@ import re from lxml.etree import ElementTree, HTML -from BeautifulSoup import BeautifulStoneSoup +from bs4 import BeautifulSoup class Response(object): @@ -129,8 +129,8 @@ def parse(self, data): :return: self.response_objects """ - data_elements = BeautifulStoneSoup(data) - all_response_elements = data_elements.findAll( + data_elements = BeautifulSoup(data, 'xml') + all_response_elements = data_elements.find_all( re.compile(r'(?i)[a-z0-9]:response')) for response in all_response_elements: diff --git a/requirements.txt b/requirements.txt index f34c536..7bd2561 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -requests==0.11.1 +requests>=1.0 mock -BeautifulSoup==3.2.1 +BeautifulSoup4==4.4.0