From 0b9c61e7e7f79c3b6c8cb1c53bad165f58f673f1 Mon Sep 17 00:00:00 2001 From: Evgeny Ezhov Date: Thu, 28 Nov 2019 14:50:39 +0300 Subject: [PATCH] Fixed SonarQube analysis issues --- webdav3/client.py | 15 ++++++--------- webdav3/connection.py | 7 ++++--- webdav3/exceptions.py | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/webdav3/client.py b/webdav3/client.py index 8d138b8..0127f24 100644 --- a/webdav3/client.py +++ b/webdav3/client.py @@ -2,14 +2,15 @@ import functools import logging -import lxml.etree as etree import os -import requests import shutil import threading from io import BytesIO from re import sub +import lxml.etree as etree +import requests + from webdav3.connection import * from webdav3.exceptions import * from webdav3.urn import Urn @@ -174,7 +175,7 @@ class Client(object): if response.status_code == 404: raise RemoteResourceNotFound(path=path) if response.status_code == 405: - raise MethodNotSupported(name=action, server=hostname) + raise MethodNotSupported(name=action, server=self.webdav.hostname) if response.status_code >= 400: raise ResponseErrorCode(url=self.get_url(path), code=response.status_code, message=response.content) return response @@ -243,9 +244,8 @@ class Client(object): :return: list of nested file or directory names. """ directory_urn = Urn(remote_path, directory=True) - if directory_urn.path() != Client.root: - if not self.check(directory_urn.path()): - raise RemoteResourceNotFound(directory_urn.path()) + if directory_urn.path() != Client.root and not self.check(directory_urn.path()): + raise RemoteResourceNotFound(directory_urn.path()) response = self.execute_request(action='list', path=directory_urn.quote()) urns = WebDavXmlUtils.parse_get_list_response(response.content) @@ -817,9 +817,6 @@ class Resource(object): class WebDavXmlUtils: - def __init__(self): - pass - @staticmethod def parse_get_list_response(content): """Parses of response content XML from WebDAV server and extract file and directory names. diff --git a/webdav3/connection.py b/webdav3/connection.py index f24593c..dee4812 100644 --- a/webdav3/connection.py +++ b/webdav3/connection.py @@ -6,10 +6,13 @@ 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: @@ -37,7 +40,6 @@ class WebDAVSettings(ConnectionSettings): disable_check = False def __init__(self, options): - self.options = dict() for key in self.keys: @@ -49,7 +51,6 @@ class WebDAVSettings(ConnectionSettings): self.root = self.root.rstrip(Urn.separate) def is_valid(self): - if not self.hostname: raise OptionNotValid(name="hostname", value=self.hostname, ns=self.ns) diff --git a/webdav3/exceptions.py b/webdav3/exceptions.py index 096c1f3..718cc7f 100644 --- a/webdav3/exceptions.py +++ b/webdav3/exceptions.py @@ -96,7 +96,7 @@ class ResponseErrorCode(WebDavException): class NotEnoughSpace(WebDavException): def __init__(self): - pass + self.message = "Not enough space on the server" def __str__(self): - return "Not enough space on the server" + return self.message