|
|
|
@ -3,6 +3,8 @@
|
|
|
|
|
This module defines the objects for notifying the caller about the
|
|
|
|
|
results of queries.
|
|
|
|
|
"""
|
|
|
|
|
import typing as T
|
|
|
|
|
from typing import overload
|
|
|
|
|
from result import QueryStatus
|
|
|
|
|
from colorama import Fore, Style
|
|
|
|
|
import webbrowser
|
|
|
|
@ -10,6 +12,8 @@ import webbrowser
|
|
|
|
|
# Global variable to count the number of results.
|
|
|
|
|
globvar = 0
|
|
|
|
|
|
|
|
|
|
if T.TYPE_CHECKING:
|
|
|
|
|
from result import QueryResult
|
|
|
|
|
|
|
|
|
|
class QueryNotify:
|
|
|
|
|
"""Query Notify Object.
|
|
|
|
@ -20,7 +24,7 @@ class QueryNotify:
|
|
|
|
|
override the methods to implement specific functionality.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self, result=None):
|
|
|
|
|
def __init__(self, result: T.Optional["QueryResult"] = None):
|
|
|
|
|
"""Create Query Notify Object.
|
|
|
|
|
|
|
|
|
|
Contains information about a specific method of notifying the results
|
|
|
|
@ -39,7 +43,7 @@ class QueryNotify:
|
|
|
|
|
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
def start(self, message=None):
|
|
|
|
|
def start(self, message: T.Optional["QueryResult"] = None):
|
|
|
|
|
"""Notify Start.
|
|
|
|
|
|
|
|
|
|
Notify method for start of query. This method will be called before
|
|
|
|
@ -58,7 +62,7 @@ class QueryNotify:
|
|
|
|
|
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
def update(self, result):
|
|
|
|
|
def update(self, result: T.Optional["QueryResult"] = None):
|
|
|
|
|
"""Notify Update.
|
|
|
|
|
|
|
|
|
|
Notify method for query result. This method will typically be
|
|
|
|
@ -77,7 +81,7 @@ class QueryNotify:
|
|
|
|
|
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
def finish(self, message=None):
|
|
|
|
|
def finish(self, message: T.Optional["QueryResult"] = None):
|
|
|
|
|
"""Notify Finish.
|
|
|
|
|
|
|
|
|
|
Notify method for finish of query. This method will be called after
|
|
|
|
@ -114,7 +118,13 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
|
Query notify class that prints results.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self, result=None, verbose=False, print_all=False, browse=False):
|
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
result: T.Optional["QueryResult"] = None,
|
|
|
|
|
verbose: bool = False,
|
|
|
|
|
print_all: bool = False,
|
|
|
|
|
browse: bool = False
|
|
|
|
|
):
|
|
|
|
|
"""Create Query Notify Print Object.
|
|
|
|
|
|
|
|
|
|
Contains information about a specific method of notifying the results
|
|
|
|
@ -139,7 +149,7 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def start(self, message):
|
|
|
|
|
def start(self, message: str) -> None:
|
|
|
|
|
"""Notify Start.
|
|
|
|
|
|
|
|
|
|
Will print the title to the standard output.
|
|
|
|
@ -179,7 +189,7 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
|
globvar += 1
|
|
|
|
|
return globvar
|
|
|
|
|
|
|
|
|
|
def update(self, result):
|
|
|
|
|
def update(self, result: T.Optional["QueryResult"] = None):
|
|
|
|
|
"""Notify Update.
|
|
|
|
|
|
|
|
|
|
Will print the query result to the standard output.
|
|
|
|
@ -256,7 +266,7 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def finish(self, message="The processing has been finished."):
|
|
|
|
|
def finish(self, message: str = "The processing has been finished.") -> None:
|
|
|
|
|
"""Notify Start.
|
|
|
|
|
Will print the last line to the standard output.
|
|
|
|
|
Keyword Arguments:
|
|
|
|
|