|
|
@ -6,6 +6,7 @@ results of queries.
|
|
|
|
from result import QueryStatus
|
|
|
|
from result import QueryStatus
|
|
|
|
from colorama import Fore, Style
|
|
|
|
from colorama import Fore, Style
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
globvar = 0
|
|
|
|
|
|
|
|
|
|
|
|
class QueryNotify:
|
|
|
|
class QueryNotify:
|
|
|
|
"""Query Notify Object.
|
|
|
|
"""Query Notify Object.
|
|
|
@ -52,7 +53,7 @@ class QueryNotify:
|
|
|
|
Nothing.
|
|
|
|
Nothing.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# return
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
|
|
def update(self, result):
|
|
|
|
def update(self, result):
|
|
|
|
"""Notify Update.
|
|
|
|
"""Notify Update.
|
|
|
@ -101,8 +102,7 @@ class QueryNotify:
|
|
|
|
Return Value:
|
|
|
|
Return Value:
|
|
|
|
Nicely formatted string to get information about this object.
|
|
|
|
Nicely formatted string to get information about this object.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return str(self.result)
|
|
|
|
return str(self.result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QueryNotifyPrint(QueryNotify):
|
|
|
|
class QueryNotifyPrint(QueryNotify):
|
|
|
|
"""Query Notify Print Object.
|
|
|
|
"""Query Notify Print Object.
|
|
|
@ -132,7 +132,7 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
self.print_all = print_all
|
|
|
|
self.print_all = print_all
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def start(self, message):
|
|
|
|
def start(self, message):
|
|
|
|
"""Notify Start.
|
|
|
|
"""Notify Start.
|
|
|
|
|
|
|
|
|
|
|
@ -185,6 +185,20 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
|
|
|
|
|
|
|
|
# return
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def countResults(self):
|
|
|
|
|
|
|
|
"""Count the number of results. Every time the fuction is called,
|
|
|
|
|
|
|
|
the number of results is increasing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
The number of results by the time we call the function.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
global globvar
|
|
|
|
|
|
|
|
globvar += 1
|
|
|
|
|
|
|
|
return globvar
|
|
|
|
|
|
|
|
|
|
|
|
def update(self, result):
|
|
|
|
def update(self, result):
|
|
|
|
"""Notify Update.
|
|
|
|
"""Notify Update.
|
|
|
|
|
|
|
|
|
|
|
@ -206,6 +220,7 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
|
|
|
|
|
|
|
|
# Output to the terminal is desired.
|
|
|
|
# Output to the terminal is desired.
|
|
|
|
if result.status == QueryStatus.CLAIMED:
|
|
|
|
if result.status == QueryStatus.CLAIMED:
|
|
|
|
|
|
|
|
self.countResults()
|
|
|
|
print(Style.BRIGHT + Fore.WHITE + "[" +
|
|
|
|
print(Style.BRIGHT + Fore.WHITE + "[" +
|
|
|
|
Fore.GREEN + "+" +
|
|
|
|
Fore.GREEN + "+" +
|
|
|
|
Fore.WHITE + "]" +
|
|
|
|
Fore.WHITE + "]" +
|
|
|
@ -213,7 +228,7 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
Fore.GREEN +
|
|
|
|
Fore.GREEN +
|
|
|
|
f" {self.result.site_name}: " +
|
|
|
|
f" {self.result.site_name}: " +
|
|
|
|
Style.RESET_ALL +
|
|
|
|
Style.RESET_ALL +
|
|
|
|
f"{self.result.site_url_user}")
|
|
|
|
f"{self.result.site_url_user}")
|
|
|
|
|
|
|
|
|
|
|
|
elif result.status == QueryStatus.AVAILABLE:
|
|
|
|
elif result.status == QueryStatus.AVAILABLE:
|
|
|
|
if self.print_all:
|
|
|
|
if self.print_all:
|
|
|
@ -255,11 +270,19 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
Will print the last line to the standard output.
|
|
|
|
Will print the last line to the standard output.
|
|
|
|
Keyword Arguments:
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
self -- This object.
|
|
|
|
message -- The last phrase.
|
|
|
|
message -- The 2 last phrases.
|
|
|
|
Return Value:
|
|
|
|
Return Value:
|
|
|
|
Nothing.
|
|
|
|
Nothing.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
numberOfResults = self.countResults() - 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
title = "Results:"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(Style.BRIGHT + Fore.GREEN + "[" +
|
|
|
|
|
|
|
|
Fore.YELLOW + "*" +
|
|
|
|
|
|
|
|
Fore.GREEN + f"] {title}" +
|
|
|
|
|
|
|
|
Fore.WHITE + f" {numberOfResults}" )
|
|
|
|
|
|
|
|
|
|
|
|
title = "End"
|
|
|
|
title = "End"
|
|
|
|
|
|
|
|
|
|
|
|
print('\r') # An empty line between last line of main output and last line(more clear output)
|
|
|
|
print('\r') # An empty line between last line of main output and last line(more clear output)
|
|
|
@ -282,4 +305,4 @@ class QueryNotifyPrint(QueryNotify):
|
|
|
|
Return Value:
|
|
|
|
Return Value:
|
|
|
|
Nicely formatted string to get information about this object.
|
|
|
|
Nicely formatted string to get information about this object.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return str(self.result)
|
|
|
|
return str(self.result)
|