mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Clean up other Python files (#11379)
* Address issues found by ruff check. * Make mypy happy; remove some Python 2 compat code. * Also declare port1.
This commit is contained in:
@@ -9,13 +9,8 @@ import os
|
||||
import posixpath
|
||||
import sys
|
||||
|
||||
try:
|
||||
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
||||
from urllib.parse import unquote
|
||||
except ImportError:
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from urllib import unquote
|
||||
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
||||
# Argument parsing
|
||||
@@ -23,8 +18,8 @@ if len(sys.argv) != 4:
|
||||
print(f"Syntax: {sys.argv[0]} <bind> <port> <path>")
|
||||
sys.exit(-1)
|
||||
|
||||
HOST, PORT, PATH = sys.argv[1:4]
|
||||
PORT = int(PORT)
|
||||
HOST, PORT_str, PATH = sys.argv[1:4]
|
||||
PORT = int(PORT_str)
|
||||
|
||||
|
||||
# The HTTP request handler
|
||||
@@ -40,7 +35,7 @@ class Handler(SimpleHTTPRequestHandler):
|
||||
trailing_slash = path.rstrip().endswith("/")
|
||||
try:
|
||||
path = unquote(path, errors="surrogatepass")
|
||||
except (UnicodeDecodeError, TypeError) as exc:
|
||||
except (UnicodeDecodeError, TypeError):
|
||||
path = unquote(path)
|
||||
path = posixpath.normpath(path)
|
||||
words = path.split("/")
|
||||
|
||||
Reference in New Issue
Block a user