improve doc strings and comments and remove useless exceptions.

This commit is contained in:
Akash Mahanty
2022-02-09 14:32:15 +05:30
parent 6d233f24fc
commit 25eb709ade
7 changed files with 44 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
"""
Module that makes waybackpy a CLI tool.
Module responsible for enabling waybackpy to function as a CLI tool.
"""
import os
@@ -18,24 +18,30 @@ from .cdx_api import WaybackMachineCDXServerAPI
from .save_api import WaybackMachineSaveAPI
from .utils import DEFAULT_USER_AGENT
from .wrapper import Url
from .exceptions import ArchiveNotInAvailabilityAPIResponse
def echo_availability_api(
availability_api_instance: WaybackMachineAvailabilityAPI, json: bool
) -> None:
"""
Output availability API depending functions.
Near, oldest and newest output by this method.
Output for method that use the availability API.
Near, oldest and newest output via this function.
"""
if not availability_api_instance.archive_url:
archive_url = (
try:
if availability_api_instance.archive_url:
archive_url = availability_api_instance.archive_url
except ArchiveNotInAvailabilityAPIResponse as error:
message = (
"NO ARCHIVE FOUND - The requested URL is probably "
+ "not yet archived or if the URL was recently archived then it is "
+ "not yet available via the Wayback Machine's availability API "
+ "because of database lag and should be available after some time."
)
else:
archive_url = availability_api_instance.archive_url
click.echo(message + "\nJSON response:\n" + str(error), err=True)
return
click.echo("Archive URL:")
click.echo(archive_url)
if json:
@@ -45,7 +51,7 @@ def echo_availability_api(
def handle_cdx(data: List[Any]) -> None:
"""
Handles the CDX CLI options and output.
Handles the CDX CLI options and output format.
"""
url = data[0]
user_agent = data[1]