From d31bc52d4139cc8acbe09816069ade1b1c8a4bc6 Mon Sep 17 00:00:00 2001 From: Martin Wendt Date: Wed, 11 Dec 2024 21:43:04 +0100 Subject: [PATCH] tox -e format --- tests/benchmarks.py | 3 +-- tests/test_http.py | 5 +++-- tests/test_litmus.py | 1 + tests/test_lock_manager.py | 1 + tests/test_property_manager.py | 1 + tests/test_scripted.py | 9 +++++---- tests/util.py | 1 + wsgidav/dav_error.py | 1 + wsgidav/dav_provider.py | 1 + wsgidav/dc/base_dc.py | 1 + wsgidav/dc/nt_dc.py | 2 +- wsgidav/dc/pam_dc.py | 1 + wsgidav/dc/simple_dc.py | 1 + wsgidav/default_conf.py | 1 + wsgidav/dir_browser/_dir_browser.py | 1 + wsgidav/error_printer.py | 1 + wsgidav/fs_dav_provider.py | 1 + wsgidav/http_authenticator.py | 2 +- wsgidav/lock_man/lock_manager.py | 1 + wsgidav/lock_man/lock_storage.py | 1 + wsgidav/mw/cors.py | 1 + wsgidav/mw/debug_filter.py | 1 + wsgidav/prop_man/couch_property_manager.py | 5 ++--- wsgidav/prop_man/mongo_property_manager.py | 1 + wsgidav/prop_man/property_manager.py | 1 + wsgidav/request_resolver.py | 1 + wsgidav/request_server.py | 20 ++++++++++---------- wsgidav/samples/dav_provider_tools.py | 1 + wsgidav/samples/hg_dav_provider.py | 1 + wsgidav/samples/mongo_dav_provider.py | 1 + wsgidav/samples/mysql_dav_provider.py | 1 + wsgidav/samples/virtual_dav_provider.py | 3 ++- wsgidav/server/ext_wsgiutils_server.py | 1 + wsgidav/server/run_reloading_server.py | 1 + wsgidav/server/server_sample.py | 1 + wsgidav/stream_tools.py | 1 + wsgidav/wsgidav_app.py | 1 + wsgidav/xml_tools.py | 1 + 38 files changed, 55 insertions(+), 24 deletions(-) diff --git a/tests/benchmarks.py b/tests/benchmarks.py index ee0980a..a397385 100644 --- a/tests/benchmarks.py +++ b/tests/benchmarks.py @@ -47,6 +47,7 @@ subfolder10-10/ file10-10-1.txt -> 1k """ + import datetime import logging import platform @@ -80,7 +81,6 @@ def _setup_fixture(opts, client): def _bench_litmus(opts): - try: with Timing("litmus test suite"): # Run litmus test suite without printing output @@ -196,7 +196,6 @@ def _bench_script(opts): def run_benchmarks(opts): - py_version = "{}.{}.{}".format(*sys.version_info) print("#-- WsgiDAV Benchmark ---------------------------------------------") diff --git a/tests/test_http.py b/tests/test_http.py index 43566bd..649a8b0 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -2,10 +2,11 @@ # Licensed under the MIT license: # http://www.opensource.org/licenses/mit-license.php """ - Functional test suite for WsgiDAV. +Functional test suite for WsgiDAV. - This test suite uses requests to generate HTTP requests. +This test suite uses requests to generate HTTP requests. """ + import unittest import requests diff --git a/tests/test_litmus.py b/tests/test_litmus.py index 025cb6c..074bd11 100644 --- a/tests/test_litmus.py +++ b/tests/test_litmus.py @@ -72,6 +72,7 @@ See here for details on the Docker image: https://github.com/mar10/docker-litmus """ + import subprocess import unittest diff --git a/tests/test_lock_manager.py b/tests/test_lock_manager.py index 565bd88..3c232ab 100644 --- a/tests/test_lock_manager.py +++ b/tests/test_lock_manager.py @@ -2,6 +2,7 @@ # Licensed under the MIT license: # http://www.opensource.org/licenses/mit-license.php """Unit test for lock_manager.py""" + import os import unittest from tempfile import gettempdir diff --git a/tests/test_property_manager.py b/tests/test_property_manager.py index ed12a5e..17c7189 100644 --- a/tests/test_property_manager.py +++ b/tests/test_property_manager.py @@ -2,6 +2,7 @@ # Licensed under the MIT license: # http://www.opensource.org/licenses/mit-license.php """Unit test for property_manager.py""" + import os import unittest from tempfile import gettempdir diff --git a/tests/test_scripted.py b/tests/test_scripted.py index da13efc..1be8a99 100644 --- a/tests/test_scripted.py +++ b/tests/test_scripted.py @@ -2,13 +2,14 @@ # Licensed under the MIT license: # http://www.opensource.org/licenses/mit-license.php """ - Functional test suite for WsgiDAV. +Functional test suite for WsgiDAV. - This test suite uses davclient to generate WebDAV requests. +This test suite uses davclient to generate WebDAV requests. - See http://chandlerproject.org/Projects/Davclient - http://svn.osafoundation.org/tools/davclient/trunk/src/davclient/davclient.py +See http://chandlerproject.org/Projects/Davclient + http://svn.osafoundation.org/tools/davclient/trunk/src/davclient/davclient.py """ + import os import time import unittest diff --git a/tests/util.py b/tests/util.py index d7316f8..ee1c008 100644 --- a/tests/util.py +++ b/tests/util.py @@ -8,6 +8,7 @@ with WsgiDavTestServer(opts): ... test methods """ + import multiprocessing import os import shutil diff --git a/wsgidav/dav_error.py b/wsgidav/dav_error.py index 3462c04..3ca52b8 100644 --- a/wsgidav/dav_error.py +++ b/wsgidav/dav_error.py @@ -5,6 +5,7 @@ """ Implements a DAVError class that is used to signal WebDAV and HTTP errors. """ + import datetime from html import escape as html_escape diff --git a/wsgidav/dav_provider.py b/wsgidav/dav_provider.py index 9d2d85d..c4daa66 100644 --- a/wsgidav/dav_provider.py +++ b/wsgidav/dav_provider.py @@ -78,6 +78,7 @@ See :doc:`reference_guide` for more information about the WsgiDAV architecture. """ + import os import sys import time diff --git a/wsgidav/dc/base_dc.py b/wsgidav/dc/base_dc.py index 68b5f1e..6cba9ef 100644 --- a/wsgidav/dc/base_dc.py +++ b/wsgidav/dc/base_dc.py @@ -36,6 +36,7 @@ TODO: Work In Progress / Subject to change """ + import sys from abc import ABC, abstractmethod from hashlib import md5 diff --git a/wsgidav/dc/nt_dc.py b/wsgidav/dc/nt_dc.py index a9b25c9..2ec601e 100644 --- a/wsgidav/dc/nt_dc.py +++ b/wsgidav/dc/nt_dc.py @@ -74,6 +74,7 @@ This class is being tested for a network domain (I'm setting one up to test). """ + import win32net import win32netcon import win32security @@ -186,7 +187,6 @@ def _is_user(self, user_name, domain, server): return False def _auth_user(self, user_name, password, domain, server): - # TODO: implement caching? # TODO: is this pre-test efficient, or should we simply try LogonUser()? diff --git a/wsgidav/dc/pam_dc.py b/wsgidav/dc/pam_dc.py index f94eea1..087eb15 100644 --- a/wsgidav/dc/pam_dc.py +++ b/wsgidav/dc/pam_dc.py @@ -8,6 +8,7 @@ See https://wsgidav.readthedocs.io/en/latest/user_guide_configure.html """ + import os import threading diff --git a/wsgidav/dc/simple_dc.py b/wsgidav/dc/simple_dc.py index c35cadd..432063d 100644 --- a/wsgidav/dc/simple_dc.py +++ b/wsgidav/dc/simple_dc.py @@ -61,6 +61,7 @@ .. _DomainControllerBase : dc/base_dc.py """ + from wsgidav import util from wsgidav.dc.base_dc import BaseDomainController diff --git a/wsgidav/default_conf.py b/wsgidav/default_conf.py index 92d10db..b2cf4f4 100644 --- a/wsgidav/default_conf.py +++ b/wsgidav/default_conf.py @@ -13,6 +13,7 @@ Default configuration. """ + # from wsgidav.mw.debug_filter import WsgiDavDebugFilter from wsgidav.dir_browser import WsgiDavDirBrowser from wsgidav.error_printer import ErrorPrinter diff --git a/wsgidav/dir_browser/_dir_browser.py b/wsgidav/dir_browser/_dir_browser.py index 1e1dd38..611d3e9 100644 --- a/wsgidav/dir_browser/_dir_browser.py +++ b/wsgidav/dir_browser/_dir_browser.py @@ -4,6 +4,7 @@ """ WSGI middleware that handles GET requests on collections to display directories. """ + import os import sys from fnmatch import fnmatch diff --git a/wsgidav/error_printer.py b/wsgidav/error_printer.py index 8c3a598..ab4483f 100644 --- a/wsgidav/error_printer.py +++ b/wsgidav/error_printer.py @@ -6,6 +6,7 @@ WSGI middleware to catch application thrown DAVErrors and return proper responses. """ + import traceback from wsgidav import util diff --git a/wsgidav/fs_dav_provider.py b/wsgidav/fs_dav_provider.py index 96206f6..f1ba9bd 100644 --- a/wsgidav/fs_dav_provider.py +++ b/wsgidav/fs_dav_provider.py @@ -14,6 +14,7 @@ and :class:`~wsgidav.fs_dav_provider.FolderResource` to represent files and directories respectively. """ + import os import shutil import stat diff --git a/wsgidav/http_authenticator.py b/wsgidav/http_authenticator.py index eba4487..9ee7de2 100644 --- a/wsgidav/http_authenticator.py +++ b/wsgidav/http_authenticator.py @@ -76,6 +76,7 @@ all methods of the domain controller as a means for developers to pass information from previous middleware or server config (if required). """ + import base64 import inspect import random @@ -333,7 +334,6 @@ def send_digest_auth_response(self, environ, start_response): return [body] def handle_digest_auth_request(self, environ, start_response): - realm = self.domain_controller.get_domain_realm(environ["PATH_INFO"], environ) if not realm: diff --git a/wsgidav/lock_man/lock_manager.py b/wsgidav/lock_man/lock_manager.py index 61929ab..db69d5f 100644 --- a/wsgidav/lock_man/lock_manager.py +++ b/wsgidav/lock_man/lock_manager.py @@ -35,6 +35,7 @@ Automatically generated unique token. """ + import random import time from pprint import pformat diff --git a/wsgidav/lock_man/lock_storage.py b/wsgidav/lock_man/lock_storage.py index a58070e..30105e6 100644 --- a/wsgidav/lock_man/lock_storage.py +++ b/wsgidav/lock_man/lock_storage.py @@ -12,6 +12,7 @@ See :class:`~wsgidav.lock_man.lock_storage.LockStorageDict` See :class:`~wsgidav.lock_man.lock_storage.LockStorageShelve` """ + import os import shelve import time diff --git a/wsgidav/mw/cors.py b/wsgidav/mw/cors.py index e046c66..35d9f82 100644 --- a/wsgidav/mw/cors.py +++ b/wsgidav/mw/cors.py @@ -6,6 +6,7 @@ Respond to CORS preflight OPTIONS request and inject CORS headers. """ + from wsgidav import util from wsgidav.mw.base_mw import BaseMiddleware diff --git a/wsgidav/mw/debug_filter.py b/wsgidav/mw/debug_filter.py index f1a7eaa..9d0b41a 100644 --- a/wsgidav/mw/debug_filter.py +++ b/wsgidav/mw/debug_filter.py @@ -50,6 +50,7 @@ debug_litmus = ["notowner_modify", "props: 16", ] """ + import sys import threading diff --git a/wsgidav/prop_man/couch_property_manager.py b/wsgidav/prop_man/couch_property_manager.py index 5099a4b..e2edf2b 100644 --- a/wsgidav/prop_man/couch_property_manager.py +++ b/wsgidav/prop_man/couch_property_manager.py @@ -21,6 +21,7 @@ } """ + from urllib.parse import quote from uuid import uuid4 @@ -130,9 +131,7 @@ def _find_descendents(self, url): if(doc.type === 'properties' && url.indexOf('%s') === 0) { emit(doc.url, { 'id': doc._id, 'url': doc.url }); } - }""" % ( - url + "/" - ) + }""" % (url + "/") vr = self.db.query(map_fun, include_docs=True) for row in vr: yield row.doc diff --git a/wsgidav/prop_man/mongo_property_manager.py b/wsgidav/prop_man/mongo_property_manager.py index af73167..2802aba 100644 --- a/wsgidav/prop_man/mongo_property_manager.py +++ b/wsgidav/prop_man/mongo_property_manager.py @@ -21,6 +21,7 @@ } """ + from urllib.parse import quote import pymongo diff --git a/wsgidav/prop_man/property_manager.py b/wsgidav/prop_man/property_manager.py index e4950da..53c057b 100644 --- a/wsgidav/prop_man/property_manager.py +++ b/wsgidav/prop_man/property_manager.py @@ -17,6 +17,7 @@ } """ + import os import shelve diff --git a/wsgidav/request_resolver.py b/wsgidav/request_resolver.py index e432dc8..89d079b 100644 --- a/wsgidav/request_resolver.py +++ b/wsgidav/request_resolver.py @@ -93,6 +93,7 @@ environ['wsgidav.destresourceAL'] = fileabstractionlayer.MyOwnFilesystemAbstractionLayer() """ + from wsgidav import util from wsgidav.dav_error import HTTP_NOT_FOUND, DAVError from wsgidav.mw.base_mw import BaseMiddleware diff --git a/wsgidav/request_server.py b/wsgidav/request_server.py index 3969e45..81c291d 100644 --- a/wsgidav/request_server.py +++ b/wsgidav/request_server.py @@ -5,6 +5,7 @@ """ WSGI application that handles one single WebDAV request. """ + from urllib.parse import unquote, urlparse from wsgidav import util, xml_tools @@ -178,9 +179,9 @@ def _send_response( assert isinstance(e, DAVError) responseEL = etree.SubElement(multistatusEL, "{DAV:}response") etree.SubElement(responseEL, "{DAV:}href").text = refurl - etree.SubElement(responseEL, "{DAV:}status").text = ( - f"HTTP/1.1 {get_http_status_string(e)}" - ) + etree.SubElement( + responseEL, "{DAV:}status" + ).text = f"HTTP/1.1 {get_http_status_string(e)}" return util.send_multi_status_response(environ, start_response, multistatusEL) @@ -352,7 +353,6 @@ def do_PROPFIND(self, environ, start_response): responsedescription = [] for child in reslist: - if propFindMode == "allprop": propList = child.get_properties("allprop") elif propFindMode == "name": @@ -364,9 +364,9 @@ def do_PROPFIND(self, environ, start_response): util.add_property_response(multistatusEL, href, propList) if responsedescription: - etree.SubElement(multistatusEL, "{DAV:}responsedescription").text = ( - "\n".join(responsedescription) - ) + etree.SubElement( + multistatusEL, "{DAV:}responsedescription" + ).text = "\n".join(responsedescription) return util.send_multi_status_response(environ, start_response, multistatusEL) @@ -478,9 +478,9 @@ def do_PROPPATCH(self, environ, start_response): href = res.get_href() util.add_property_response(multistatusEL, href, propResponseList) if responsedescription: - etree.SubElement(multistatusEL, "{DAV:}responsedescription").text = ( - "\n".join(responsedescription) - ) + etree.SubElement( + multistatusEL, "{DAV:}responsedescription" + ).text = "\n".join(responsedescription) # Send response return util.send_multi_status_response(environ, start_response, multistatusEL) diff --git a/wsgidav/samples/dav_provider_tools.py b/wsgidav/samples/dav_provider_tools.py index b19a9dc..7b509e4 100644 --- a/wsgidav/samples/dav_provider_tools.py +++ b/wsgidav/samples/dav_provider_tools.py @@ -3,6 +3,7 @@ """ Tools that make it easier to implement custom WsgiDAV providers. """ + import os import stat diff --git a/wsgidav/samples/hg_dav_provider.py b/wsgidav/samples/hg_dav_provider.py index 65f75de..2f72ffc 100644 --- a/wsgidav/samples/hg_dav_provider.py +++ b/wsgidav/samples/hg_dav_provider.py @@ -70,6 +70,7 @@ from here: http://mercurial.berkwood.com/ http://mercurial.berkwood.com/binaries/mercurial-1.4.win32-py2.6.exe """ + import os import sys import time diff --git a/wsgidav/samples/mongo_dav_provider.py b/wsgidav/samples/mongo_dav_provider.py index 76056a7..b09425e 100644 --- a/wsgidav/samples/mongo_dav_provider.py +++ b/wsgidav/samples/mongo_dav_provider.py @@ -23,6 +23,7 @@ } """ + from io import StringIO from pprint import pformat diff --git a/wsgidav/samples/mysql_dav_provider.py b/wsgidav/samples/mysql_dav_provider.py index d1cbe94..60df2cf 100644 --- a/wsgidav/samples/mysql_dav_provider.py +++ b/wsgidav/samples/mysql_dav_provider.py @@ -56,6 +56,7 @@ unnecessary queries to the database. """ + import csv import hashlib import time diff --git a/wsgidav/samples/virtual_dav_provider.py b/wsgidav/samples/virtual_dav_provider.py index b356d47..d18dd27 100644 --- a/wsgidav/samples/virtual_dav_provider.py +++ b/wsgidav/samples/virtual_dav_provider.py @@ -94,6 +94,7 @@ /by_tag/hot/My doc 1 /by_key/1 """ + import os import stat from io import BytesIO @@ -150,7 +151,7 @@ }, { "key": "3", - "title": "My doc (euro:\u20AC, uuml:��)".encode(), + "title": "My doc (euro:\u20ac, uuml:��)".encode(), "orga": "marketing", "tags": ["nice"], "status": "published", diff --git a/wsgidav/server/ext_wsgiutils_server.py b/wsgidav/server/ext_wsgiutils_server.py index 7a45cc7..e14a26b 100644 --- a/wsgidav/server/ext_wsgiutils_server.py +++ b/wsgidav/server/ext_wsgiutils_server.py @@ -52,6 +52,7 @@ run the application by specifying ``server='ext_wsgiutils'`` in the ``server.conf`` or appropriate paste configuration. """ + __docformat__ = "reStructuredText" import logging diff --git a/wsgidav/server/run_reloading_server.py b/wsgidav/server/run_reloading_server.py index 097279f..7f749bb 100644 --- a/wsgidav/server/run_reloading_server.py +++ b/wsgidav/server/run_reloading_server.py @@ -4,6 +4,7 @@ Wrapper for ``server_cli``, that restarts the server when source code is modified. """ + import os import sys from subprocess import Popen diff --git a/wsgidav/server/server_sample.py b/wsgidav/server/server_sample.py index a9ccd7d..523f8f1 100644 --- a/wsgidav/server/server_sample.py +++ b/wsgidav/server/server_sample.py @@ -4,6 +4,7 @@ """ Simple example how to a run WsgiDAV in a 3rd-party WSGI server. """ + from cheroot import wsgi from wsgidav import util diff --git a/wsgidav/stream_tools.py b/wsgidav/stream_tools.py index 90ee714..3b3758f 100644 --- a/wsgidav/stream_tools.py +++ b/wsgidav/stream_tools.py @@ -15,6 +15,7 @@ def begin_write(self, contentType=None): return queue """ + import queue from wsgidav import util diff --git a/wsgidav/wsgidav_app.py b/wsgidav/wsgidav_app.py index 9dafabf..0e0d914 100644 --- a/wsgidav/wsgidav_app.py +++ b/wsgidav/wsgidav_app.py @@ -46,6 +46,7 @@ Note: The OPTIONS method for the '*' path is handled directly. """ + import copy import inspect import platform diff --git a/wsgidav/xml_tools.py b/wsgidav/xml_tools.py index 7886782..76abd30 100644 --- a/wsgidav/xml_tools.py +++ b/wsgidav/xml_tools.py @@ -5,6 +5,7 @@ """ Small wrapper for different etree packages. """ + import logging from io import StringIO