tinydav (version 0.6.8)
index
/home/hermann/Entwürfe/hg/tinydav/tinydav/__init__.py

The tinydav WebDAV client.

 
Package Contents
       
creator
exception
util

 
Classes
       
__builtin__.object
HTTPClient
exceptions.Exception(exceptions.BaseException)
tinydav.exception.HTTPError
tinydav.exception.HTTPServerError
tinydav.exception.HTTPUserError
ExtendedWebDAVClient(CoreWebDAVClient)
WebDAVClient

 
class HTTPClient(__builtin__.object)
    Mini HTTP client.
 
This object has the following attributes:
 
host -- Given host on initialization.
port -- Given port on initialization.
protocol -- Used protocol. Either chosen by the port number or taken
            from given value in initialization.
headers -- Dictionary with headers to send with every request.
cookie -- If set with setcookie: the given object.
locks -- Mapping with locks.
 
  Methods defined here:
__init__(self, host, port=80, protocol=None, strict=False, timeout=None, source_address=None)
Initialize the WebDAV client.
 
host -- WebDAV server host.
port -- WebDAV server port.
protocol -- Override protocol name. Is either 'http' or 'https'. If
            not given, the protocol will be chosen by the port number
            automatically:
                80   -> http
                443  -> https
                8080 -> http
                8081 -> http
            Default port is 'http'.
strict -- When True, raise BadStatusLine if the status line can't be
          parsed as a valid HTTP/1.0 or 1.1 status line (see Python
          doc for httplib).
timeout -- Operations will timeout after that many seconds. Else the
           global default timeout setting is used (see Python doc for
           httplib). This argument is available since Python 2.6. It
           won't have any effect in previous version.
source_address -- A tuple of (host, port) to use as the source address
                  the HTTP connection is made from (see Python doc for
                  httplib). This argument is available since
                  Python 2.7. It won't have any effect in previous
                  versions.
connect(self, uri, headers=None)
Make CONNECT request and return HTTPResponse.
 
uri -- Path to post data to.
headers -- If given, must be a mapping with headers to set.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
delete(self, uri, content='', headers=None)
Make DELETE request and return HTTPResponse.
 
uri -- Path to post data to.
content -- File descriptor or string with content.
headers -- If given, must be a mapping with headers to set.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
get(self, uri, headers=None, query=None)
Make GET request and return status.
 
uri -- URI of the request.
headers -- Optional mapping with headers to send.
query -- Mapping with key/value-pairs to be added as query to the URI.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
head(self, uri, headers=None, query=None)
Make HEAD request and return status.
 
uri -- URI of the request.
headers -- Optional mapping with headers to send.
query -- Mapping with key/value-pairs to be added as query to the URI.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
options(self, uri, headers=None)
Make OPTIONS request and return status.
 
uri -- URI of the request.
headers -- Optional mapping with headers to send.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
post(self, uri, content='', headers=None, query=None, as_multipart=False, encoding='ascii', with_filenames=False)
Make POST request and return HTTPResponse.
 
uri -- Path to post data to.
content -- File descriptor, string or dict with content to POST. If it
           is a dict, the dict contents will be posted as content type
           application/x-www-form-urlencoded.
headers -- If given, must be a mapping with headers to set.
query -- Mapping with key/value-pairs to be added as query to the URI.
as_multipart -- Send post data as multipart/form-data. content must be
                a dict, then. If content is not a dict, then this 
                argument will be ignored. The values of the dict may be
                a subclass of email.mime.base.MIMEBase, which will be
                attached to the multipart as is, a 2-tuple containing
                the actual value (or file-like object) and an encoding
                for this value (or the content-type in case of a 
                file-like object).
encoding -- Send multipart content encoding with this encoding. Default
            is ASCII.
with_filenames -- If True, a multipart's files will be sent with the
                  filename paramenter set. Default is False.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
put(self, uri, fileobject, content_type='application/octet-stream', headers=None)
Make PUT request and return status.
 
uri -- Path for PUT.
fileobject -- File-like object or string with content to PUT.
content_type -- The content-type of the file. Default value is
                application/octet-stream.
headers -- If given, must be a dict with headers to send.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
setbasicauth(self, user, password)
Set authorization header for basic auth.
 
user -- Username
password -- Password for user.
setcookie(self, cookie)
Set cookie class to be used in requests.
 
cookie -- Cookie class from cookielib.
setssl(self, key_file=None, cert_file=None)
Set SSL key file and/or certificate chain file for HTTPS.
 
Calling this method has the side effect of setting the protocol to
https.
 
key_file -- The name of a PEM formatted file that contains your
            private key.
cert_file -- PEM formatted certificate chain file (see Python doc for
             httplib).
trace(self, uri, maxforwards=None, via=None, headers=None)
Make TRACE request and return HTTPResponse.
 
uri -- Path to post data to.
maxforwards -- Number of maximum forwards. May be None.
via -- If given, an iterable containing each station in the form
       stated in RFC2616, section 14.45.
headers -- If given, must be a mapping with headers to set.
 
Raise ValueError, if maxforward is not an int or convertable to
an int.
Raise TypeError, if via is not an iterable of string.
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
ResponseType = <class 'tinydav.HTTPResponse'>
Result from HTTP request.
 
An HTTPResponse object is a subclass of int. The int value of such an
object is the HTTP status number from the response.
 
This object has the following attributes:
 
response -- The original httplib.HTTPResponse object.
headers -- A dictionary with the received headers.
content -- The content of the response as string.
statusline -- The received HTTP status line. E.g. "HTTP/1.1 200 OK".

 
class HTTPError(exceptions.Exception)
    Base exception class for HTTP errors.
 
response -- httplib.Response object.
method -- String with uppercase method name.
 
This object has the following attributes:
  response -- The HTTPResponse object.
 
 
Method resolution order:
HTTPError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, response)
Initialize the HTTPError.
 
response -- HTTPClient or one of its subclasses.
method -- The uppercase method name where the error occured.
 
This instance has the following attributes:
 
response -- Given HTTPClient.
__repr__(self)
Return representation of an HTTPError.
__str__(self)
Return string representation of an HTTPError.

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class HTTPServerError(HTTPError)
    Exception class for 5xx HTTP errors.
 
 
Method resolution order:
HTTPServerError
HTTPError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods inherited from HTTPError:
__init__(self, response)
Initialize the HTTPError.
 
response -- HTTPClient or one of its subclasses.
method -- The uppercase method name where the error occured.
 
This instance has the following attributes:
 
response -- Given HTTPClient.
__repr__(self)
Return representation of an HTTPError.
__str__(self)
Return string representation of an HTTPError.

Data descriptors inherited from HTTPError:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class HTTPUserError(HTTPError)
    Exception class for 4xx HTTP errors.
 
 
Method resolution order:
HTTPUserError
HTTPError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods inherited from HTTPError:
__init__(self, response)
Initialize the HTTPError.
 
response -- HTTPClient or one of its subclasses.
method -- The uppercase method name where the error occured.
 
This instance has the following attributes:
 
response -- Given HTTPClient.
__repr__(self)
Return representation of an HTTPError.
__str__(self)
Return string representation of an HTTPError.

Data descriptors inherited from HTTPError:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class WebDAVClient(ExtendedWebDAVClient)
    Mini WebDAV client.
 
This object has the following attributes:
 
host -- Given host on initialization.
port -- Given port on initialization.
protocol -- Used protocol. Either chosen by the port number or taken
            from given value in initialization.
headers -- Dictionary with headers to send with every request.
cookie -- If set with setcookie: the given object.
 
 
Method resolution order:
WebDAVClient
ExtendedWebDAVClient
CoreWebDAVClient
HTTPClient
__builtin__.object

Methods inherited from ExtendedWebDAVClient:
report(self, uri, depth=0, properties=None, elements=None, namespaces=None, headers=None)
Make a REPORT request and return status.
 
uri -- Resource or collection to get report for.
depth -- Either 0 or 1 or "infinity". Default is zero.
properties -- If given, an iterable with all requested properties is
              expected.
elements -- An iterable with additional XML (ElementTree) elements to
            append to the version-tree.
namespaces -- Mapping with namespaces for given properties, if needed.
headers -- If given, must be a mapping with headers to set.
 
Raise ValueError, if an illegal depth value was given.
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.

Methods inherited from CoreWebDAVClient:
__init__(self, host, port=80, protocol=None)
Initialize the WebDAV client.
 
host -- WebDAV server host.
port -- WebDAV server port.
protocol -- Override protocol name. Is either 'http' or 'https'. If
            not given, the protocol will be chosen by the port number
            automatically:
                80   -> http
                443  -> https
                8080 -> http
                8081 -> http
            Default port is 'http'.
copy(self, source, destination, depth='infinity', overwrite=None, headers=None)
Make COPY request and return WebDAVResponse.
 
source -- Path of resource to copy.
destination -- Path of destination to copy source to.
depth -- Either 0 or "infinity". Default is the latter.
overwrite -- If not None, then a boolean indicating whether the
             Overwrite header ist set to "T" (True) or "F" (False).
headers -- If given, must be a mapping with headers to set.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
delete(self, uri, headers=None)
Make DELETE request and return WebDAVResponse.
 
uri -- Path of resource or collection to delete.
headers -- If given, must be a mapping with headers to set.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
lock(self, uri, scope='exclusive', type_='write', owner=None, timeout=None, depth=None, headers=None)
Make LOCK request and return DAVLock instance.
 
uri -- Resource to get lock on.
scope -- Lock scope: One of "exclusive" (default) or "shared".
type_ -- Lock type: "write" (default) only. Any other value allowed by
         this library.
owner -- Content of owner element. May be None, a string or an
         ElementTree element.
timeout -- Value for the timeout header. Either "infinite" or a number
           representing the seconds (not greater than 2^32 - 1).
headers -- If given, must be a mapping with headers to set.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
mkcol(self, uri, headers=None)
Make MKCOL request and return status.
 
uri -- Path to create.
headers -- If given, must be a dict with headers to send.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
move(self, source, destination, depth='infinity', overwrite=None, headers=None)
Make MOVE request and return WebDAVResponse.
 
source -- Path of resource to move.
destination -- Path of destination to move source to.
depth -- Either 0 or "infinity". Default is the latter.
overwrite -- If not None, then a boolean indicating whether the
             Overwrite header ist set to "T" (True) or "F" (False).
headers -- If given, must be a mapping with headers to set.
 
Raise ValueError, if an illegal depth was given.
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
propfind(self, uri, depth=0, names=False, properties=None, include=None, namespaces=None, headers=None)
Make PROPFIND request and return status.
 
uri -- Path for PROPFIND.
depth -- Depth for PROFIND request. Default is zero.
names -- If True, only the available namespace names are returned.
properties -- If given, an iterable with all requested properties is
              expected.
include -- If properties is not given, then additional properties can
           be requested with this argument.
namespaces -- Mapping with namespaces for given properties, if needed.
headers -- If given, must be a dict with headers to send.
 
Raise ValueError, if illegal depth was given or if properties and
include arguments were given.
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
proppatch(self, uri, setprops=None, delprops=None, namespaces=None, headers=None)
Make PROPPATCH request and return status.
 
uri -- Path to resource to set properties.
setprops -- Mapping with properties to set.
delprops -- Iterable with properties to remove.
namespaces -- dict with namespaces: name -> URI.
headers -- If given, must be a dict with headers to send.
 
Either setprops or delprops or both of them must be given, else
ValueError will be risen.
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
unlock(self, uri_or_lock, locktoken=None, headers=None)
Make UNLOCK request and return WebDAVResponse.
 
uri_or_lock -- Resource URI to unlock or WebDAVLockResponse.
locktoken -- Use this lock token for unlocking. If not given, the
             registered locks (self.locks) will be referenced.
headers -- If given, must be a mapping with headers to set.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.

Data and other attributes inherited from CoreWebDAVClient:
ResponseType = <class 'tinydav.WebDAVResponse'>
Result from WebDAV request.
 
A WebDAVResponse object is a subclass of int. The int value of such an
object is the HTTP status number from the response.
 
This object has the following attributes:
 
response -- The original httplib.HTTPResponse object.
headers -- A dictionary with the received headers.
content -- The content of the response as string.
statusline -- The received HTTP status line. E.g. "HTTP/1.1 200 OK".
is_multistatus -- True, if the response's content is a multi-status
                  response.
 
You can iterate over a WebDAVResponse object. If the received data was
a multi-status response, the iterator will yield a MultiStatusResponse
object per result. If it was no multi-status response, the iterator will
just yield this WebDAVResponse object.
 
The length of a WebDAVResponse object is 1, except for multi-status 
responses. The length will then be the number of results in the
multi-status.

Methods inherited from HTTPClient:
connect(self, uri, headers=None)
Make CONNECT request and return HTTPResponse.
 
uri -- Path to post data to.
headers -- If given, must be a mapping with headers to set.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
get(self, uri, headers=None, query=None)
Make GET request and return status.
 
uri -- URI of the request.
headers -- Optional mapping with headers to send.
query -- Mapping with key/value-pairs to be added as query to the URI.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
head(self, uri, headers=None, query=None)
Make HEAD request and return status.
 
uri -- URI of the request.
headers -- Optional mapping with headers to send.
query -- Mapping with key/value-pairs to be added as query to the URI.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
options(self, uri, headers=None)
Make OPTIONS request and return status.
 
uri -- URI of the request.
headers -- Optional mapping with headers to send.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
post(self, uri, content='', headers=None, query=None, as_multipart=False, encoding='ascii', with_filenames=False)
Make POST request and return HTTPResponse.
 
uri -- Path to post data to.
content -- File descriptor, string or dict with content to POST. If it
           is a dict, the dict contents will be posted as content type
           application/x-www-form-urlencoded.
headers -- If given, must be a mapping with headers to set.
query -- Mapping with key/value-pairs to be added as query to the URI.
as_multipart -- Send post data as multipart/form-data. content must be
                a dict, then. If content is not a dict, then this 
                argument will be ignored. The values of the dict may be
                a subclass of email.mime.base.MIMEBase, which will be
                attached to the multipart as is, a 2-tuple containing
                the actual value (or file-like object) and an encoding
                for this value (or the content-type in case of a 
                file-like object).
encoding -- Send multipart content encoding with this encoding. Default
            is ASCII.
with_filenames -- If True, a multipart's files will be sent with the
                  filename paramenter set. Default is False.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
put(self, uri, fileobject, content_type='application/octet-stream', headers=None)
Make PUT request and return status.
 
uri -- Path for PUT.
fileobject -- File-like object or string with content to PUT.
content_type -- The content-type of the file. Default value is
                application/octet-stream.
headers -- If given, must be a dict with headers to send.
 
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.
setbasicauth(self, user, password)
Set authorization header for basic auth.
 
user -- Username
password -- Password for user.
setcookie(self, cookie)
Set cookie class to be used in requests.
 
cookie -- Cookie class from cookielib.
setssl(self, key_file=None, cert_file=None)
Set SSL key file and/or certificate chain file for HTTPS.
 
Calling this method has the side effect of setting the protocol to
https.
 
key_file -- The name of a PEM formatted file that contains your
            private key.
cert_file -- PEM formatted certificate chain file (see Python doc for
             httplib).
trace(self, uri, maxforwards=None, via=None, headers=None)
Make TRACE request and return HTTPResponse.
 
uri -- Path to post data to.
maxforwards -- Number of maximum forwards. May be None.
via -- If given, an iterable containing each station in the form
       stated in RFC2616, section 14.45.
headers -- If given, must be a mapping with headers to set.
 
Raise ValueError, if maxforward is not an int or convertable to
an int.
Raise TypeError, if via is not an iterable of string.
Raise HTTPUserError on 4xx HTTP status codes.
Raise HTTPServerError on 5xx HTTP status codes.

Data descriptors inherited from HTTPClient:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        __all__ = ('HTTPError', 'HTTPUserError', 'HTTPServerError', 'HTTPClient', 'WebDAVClient')
__author__ = 'Manuel Hermann <manuel-hermann@gmx.net>'
__license__ = 'LGPL'
__version__ = '0.6.8'

 
Author
        Manuel Hermann <manuel-hermann@gmx.net>