Improve documentation
This commit is contained in:
@@ -22,7 +22,7 @@ def handle(client: HTTPClient, msg: Message, command: AbstractCommand, directory
|
||||
|
||||
@param client: the client which sent the request.
|
||||
@param msg: the response message
|
||||
@param command: the command of the sent request message
|
||||
@param command: the command of the sent request-message
|
||||
@param directory: the directory to download the response to (if available)
|
||||
"""
|
||||
handler = BasicResponseHandler(client, msg, command)
|
||||
@@ -81,7 +81,7 @@ class BasicResponseHandler(ResponseHandler):
|
||||
for line in self.retriever.retrieve():
|
||||
try:
|
||||
logging.debug("%s", line.decode(FORMAT))
|
||||
except Exception:
|
||||
except UnicodeDecodeError:
|
||||
logging.debug("%r", line)
|
||||
|
||||
logging.debug("] done.")
|
||||
@@ -223,7 +223,7 @@ class HTMLDownloadHandler(DownloadHandler):
|
||||
|
||||
def _download_images(self, tmp_path, target_path, charset=FORMAT):
|
||||
"""
|
||||
Downloads images referenced in the html of `tmp_filename` and replaces the references in the html
|
||||
Download images referenced in the html of `tmp_filename` and replaces the references in the html
|
||||
and writes it to `target_filename`.
|
||||
@param tmp_path: the path to the temporary html file
|
||||
@param target_path: the path for the final html file
|
||||
@@ -247,7 +247,7 @@ class HTMLDownloadHandler(DownloadHandler):
|
||||
processed = {}
|
||||
to_replace = []
|
||||
|
||||
# Find all <img> tags and the urls from the corresponding `src` fields
|
||||
# Find all <img> tags, and the urls from the corresponding `src` fields
|
||||
for m in IMG_REGEX.finditer(html):
|
||||
url_start = m.start(1)
|
||||
url_end = m.end(1)
|
||||
@@ -272,7 +272,7 @@ class HTMLDownloadHandler(DownloadHandler):
|
||||
logging.error("Failed to download image: %s, skipping...", target, exc_info=e)
|
||||
|
||||
# reverse the list so urls at the bottom of the html file are processed first.
|
||||
# Otherwise our start and end positions won't be correct.
|
||||
# Otherwise, our start and end positions won't be correct.
|
||||
to_replace.reverse()
|
||||
for (start, end, path) in to_replace:
|
||||
html = html[:start] + path + html[end:]
|
||||
|
Reference in New Issue
Block a user