Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions python_webdav/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions python_webdav/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re

from lxml.etree import ElementTree, HTML
from BeautifulSoup import BeautifulStoneSoup
from bs4 import BeautifulSoup


class Response(object):
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
requests==0.11.1
requests>=1.0
mock
BeautifulSoup==3.2.1
BeautifulSoup4==4.4.0