added completly new version for haslach 2025
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1253
.venv/lib/python3.7/site-packages/webdav3/client.py
Normal file
1253
.venv/lib/python3.7/site-packages/webdav3/client.py
Normal file
File diff suppressed because it is too large
Load Diff
73
.venv/lib/python3.7/site-packages/webdav3/connection.py
Normal file
73
.venv/lib/python3.7/site-packages/webdav3/connection.py
Normal file
@@ -0,0 +1,73 @@
|
||||
from os.path import exists
|
||||
|
||||
from webdav3.exceptions import *
|
||||
from webdav3.urn import Urn
|
||||
|
||||
|
||||
class ConnectionSettings:
|
||||
def is_valid(self):
|
||||
"""
|
||||
Method checks is settings are valid
|
||||
:return: True if settings are valid otherwise False
|
||||
"""
|
||||
pass
|
||||
|
||||
def valid(self):
|
||||
try:
|
||||
self.is_valid()
|
||||
except OptionNotValid:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
class WebDAVSettings(ConnectionSettings):
|
||||
ns = "webdav:"
|
||||
prefix = "webdav_"
|
||||
keys = {'hostname', 'login', 'password', 'token', 'root', 'cert_path', 'key_path', 'recv_speed', 'send_speed',
|
||||
'verbose', 'disable_check', 'override_methods', 'timeout', 'chunk_size'}
|
||||
|
||||
def __init__(self, options):
|
||||
self.hostname = None
|
||||
self.login = None
|
||||
self.password = None
|
||||
self.token = None
|
||||
self.root = None
|
||||
self.cert_path = None
|
||||
self.key_path = None
|
||||
self.recv_speed = None
|
||||
self.send_speed = None
|
||||
self.verbose = None
|
||||
self.disable_check = False
|
||||
self.override_methods = {}
|
||||
self.timeout = 30
|
||||
self.chunk_size = 65536
|
||||
|
||||
self.options = dict()
|
||||
|
||||
for key in self.keys:
|
||||
value = options.get(key, '')
|
||||
if not (self.__dict__[key] and not value):
|
||||
self.options[key] = value
|
||||
self.__dict__[key] = value
|
||||
|
||||
self.root = Urn(self.root).quote() if self.root else ''
|
||||
self.root = self.root.rstrip(Urn.separate)
|
||||
self.hostname = self.hostname.rstrip(Urn.separate)
|
||||
|
||||
def is_valid(self):
|
||||
if not self.hostname:
|
||||
raise OptionNotValid(name="hostname", value=self.hostname, ns=self.ns)
|
||||
|
||||
if self.cert_path and not exists(self.cert_path):
|
||||
raise OptionNotValid(name="cert_path", value=self.cert_path, ns=self.ns)
|
||||
|
||||
if self.key_path and not exists(self.key_path):
|
||||
raise OptionNotValid(name="key_path", value=self.key_path, ns=self.ns)
|
||||
|
||||
if self.key_path and not self.cert_path:
|
||||
raise OptionNotValid(name="cert_path", value=self.cert_path, ns=self.ns)
|
||||
|
||||
if self.password and not self.login:
|
||||
raise OptionNotValid(name="login", value=self.login, ns=self.ns)
|
||||
return True
|
102
.venv/lib/python3.7/site-packages/webdav3/exceptions.py
Normal file
102
.venv/lib/python3.7/site-packages/webdav3/exceptions.py
Normal file
@@ -0,0 +1,102 @@
|
||||
class WebDavException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class NotValid(WebDavException):
|
||||
pass
|
||||
|
||||
|
||||
class OptionNotValid(NotValid):
|
||||
def __init__(self, name, value, ns=""):
|
||||
self.name = name
|
||||
self.value = value
|
||||
self.ns = ns
|
||||
|
||||
def __str__(self):
|
||||
return "Option ({ns}{name}={value}) have invalid name or value".format(ns=self.ns, name=self.name,
|
||||
value=self.value)
|
||||
|
||||
|
||||
class CertificateNotValid(NotValid):
|
||||
pass
|
||||
|
||||
|
||||
class NotFound(WebDavException):
|
||||
pass
|
||||
|
||||
|
||||
class LocalResourceNotFound(NotFound):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def __str__(self):
|
||||
return "Local file: {path} not found".format(path=self.path)
|
||||
|
||||
|
||||
class RemoteResourceNotFound(NotFound):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def __str__(self):
|
||||
return "Remote resource: {path} not found".format(path=self.path)
|
||||
|
||||
|
||||
class RemoteParentNotFound(NotFound):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def __str__(self):
|
||||
return "Remote parent for: {path} not found".format(path=self.path)
|
||||
|
||||
|
||||
class MethodNotSupported(WebDavException):
|
||||
def __init__(self, name, server):
|
||||
self.name = name
|
||||
self.server = server
|
||||
|
||||
def __str__(self):
|
||||
return "Method '{name}' not supported for {server}".format(name=self.name, server=self.server)
|
||||
|
||||
|
||||
class ConnectionException(WebDavException):
|
||||
def __init__(self, exception):
|
||||
self.exception = exception
|
||||
|
||||
def __str__(self):
|
||||
return self.exception.__str__()
|
||||
|
||||
|
||||
class NoConnection(WebDavException):
|
||||
def __init__(self, hostname):
|
||||
self.hostname = hostname
|
||||
|
||||
def __str__(self):
|
||||
return "No connection with {hostname}".format(hostname=self.hostname)
|
||||
|
||||
|
||||
# This exception left only for supporting original library interface.
|
||||
class NotConnection(WebDavException):
|
||||
def __init__(self, hostname):
|
||||
self.hostname = hostname
|
||||
|
||||
def __str__(self):
|
||||
return "No connection with {hostname}".format(hostname=self.hostname)
|
||||
|
||||
|
||||
class ResponseErrorCode(WebDavException):
|
||||
def __init__(self, url, code, message):
|
||||
self.url = url
|
||||
self.code = code
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
return "Request to {url} failed with code {code} and message: {message}".format(url=self.url, code=self.code,
|
||||
message=self.message)
|
||||
|
||||
|
||||
class NotEnoughSpace(WebDavException):
|
||||
def __init__(self):
|
||||
self.message = "Not enough space on the server"
|
||||
|
||||
def __str__(self):
|
||||
return self.message
|
59
.venv/lib/python3.7/site-packages/webdav3/urn.py
Normal file
59
.venv/lib/python3.7/site-packages/webdav3/urn.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from re import sub
|
||||
from urllib.parse import unquote, quote, urlsplit
|
||||
|
||||
|
||||
class Urn(object):
|
||||
separate = "/"
|
||||
|
||||
def __init__(self, path, directory=False):
|
||||
|
||||
self._path = quote(path)
|
||||
expressions = "/\.+/", "/+"
|
||||
for expression in expressions:
|
||||
self._path = sub(expression, Urn.separate, self._path)
|
||||
|
||||
if not self._path.startswith(Urn.separate):
|
||||
self._path = "{begin}{end}".format(begin=Urn.separate, end=self._path)
|
||||
|
||||
if directory and not self._path.endswith(Urn.separate):
|
||||
self._path = "{begin}{end}".format(begin=self._path, end=Urn.separate)
|
||||
|
||||
def __str__(self):
|
||||
return self.path()
|
||||
|
||||
def path(self):
|
||||
return unquote(self._path)
|
||||
|
||||
def quote(self):
|
||||
return self._path
|
||||
|
||||
def filename(self):
|
||||
path_split = self._path.split(Urn.separate)
|
||||
name = path_split[-2] + Urn.separate if path_split[-1] == '' else path_split[-1]
|
||||
return unquote(name)
|
||||
|
||||
def parent(self):
|
||||
path_split = self._path.split(Urn.separate)
|
||||
nesting_level = self.nesting_level()
|
||||
parent_path_split = path_split[:nesting_level]
|
||||
parent = self.separate.join(parent_path_split) if nesting_level != 1 else Urn.separate
|
||||
if not parent.endswith(Urn.separate):
|
||||
return unquote(parent + Urn.separate)
|
||||
else:
|
||||
return unquote(parent)
|
||||
|
||||
def nesting_level(self):
|
||||
return self._path.count(Urn.separate, 0, -1)
|
||||
|
||||
def is_dir(self):
|
||||
return self._path[-1] == Urn.separate
|
||||
|
||||
@staticmethod
|
||||
def normalize_path(path):
|
||||
result = sub('/{2,}', '/', path)
|
||||
return result if len(result) < 1 or result[-1] != Urn.separate else result[:-1]
|
||||
|
||||
@staticmethod
|
||||
def compare_path(path_a, href):
|
||||
unqouted_path = Urn.separate + unquote(urlsplit(href).path)
|
||||
return Urn.normalize_path(path_a) == Urn.normalize_path(unqouted_path)
|
Reference in New Issue
Block a user