remove unnecessary if statements

pull/1218/head
Noah-20 3 years ago
parent ad029d9ec6
commit e6c47d81e5

@ -4,10 +4,10 @@ This module defines the objects for notifying the caller about the
results of queries. results of queries.
""" """
from result import QueryStatus from result import QueryStatus
from colorama import Fore, Style, init from colorama import Fore, Style
class QueryNotify(): class QueryNotify:
"""Query Notify Object. """Query Notify Object.
Base class that describes methods available to notify the results of Base class that describes methods available to notify the results of
@ -15,6 +15,7 @@ class QueryNotify():
It is intended that other classes inherit from this base class and It is intended that other classes inherit from this base class and
override the methods to implement specific functionality. override the methods to implement specific functionality.
""" """
def __init__(self, result=None): def __init__(self, result=None):
"""Create Query Notify Object. """Create Query Notify Object.
@ -110,7 +111,8 @@ class QueryNotifyPrint(QueryNotify):
Query notify class that prints results. Query notify class that prints results.
""" """
def __init__(self, result=None, verbose=False, color=True, print_all=False):
def __init__(self, result=None, verbose=False, print_all=False):
"""Create Query Notify Print Object. """Create Query Notify Print Object.
Contains information about a specific method of notifying the results Contains information about a specific method of notifying the results
@ -128,13 +130,9 @@ class QueryNotifyPrint(QueryNotify):
Nothing. Nothing.
""" """
# Colorama module's initialization.
init(autoreset=True)
super().__init__(result) super().__init__(result)
self.verbose = verbose self.verbose = verbose
self.print_all = print_all self.print_all = print_all
self.color = color
return return
@ -153,14 +151,11 @@ class QueryNotifyPrint(QueryNotify):
""" """
title = "Checking username" title = "Checking username"
if self.color: print(Style.BRIGHT + Fore.GREEN + "[" +
print(Style.BRIGHT + Fore.GREEN + "[" + Fore.YELLOW + "*" +
Fore.YELLOW + "*" + Fore.GREEN + f"] {title}" +
Fore.GREEN + f"] {title}" + Fore.WHITE + f" {message}" +
Fore.WHITE + f" {message}" + Fore.GREEN + " on:")
Fore.GREEN + " on:")
else:
print(f"[*] {title} {message} on:")
return return
@ -186,53 +181,41 @@ 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:
if self.color: print(Style.BRIGHT + Fore.WHITE + "[" +
print((Style.BRIGHT + Fore.WHITE + "[" + Fore.GREEN + "+" +
Fore.GREEN + "+" + Fore.WHITE + "]" +
Fore.WHITE + "]" + response_time_text +
response_time_text + 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}"))
else:
print(f"[+]{response_time_text} {self.result.site_name}: {self.result.site_url_user}")
elif result.status == QueryStatus.AVAILABLE: elif result.status == QueryStatus.AVAILABLE:
if self.print_all: if self.print_all:
if self.color: print(Style.BRIGHT + Fore.WHITE + "[" +
print((Style.BRIGHT + Fore.WHITE + "[" + Fore.RED + "-" +
Fore.RED + "-" + Fore.WHITE + "]" +
Fore.WHITE + "]" + response_time_text +
response_time_text + Fore.GREEN + f" {self.result.site_name}:" +
Fore.GREEN + f" {self.result.site_name}:" + Fore.YELLOW + " Not Found!")
Fore.YELLOW + " Not Found!"))
else:
print(f"[-]{response_time_text} {self.result.site_name}: Not Found!")
elif result.status == QueryStatus.UNKNOWN: elif result.status == QueryStatus.UNKNOWN:
if self.print_all: if self.print_all:
if self.color: print(Style.BRIGHT + Fore.WHITE + "[" +
print(Style.BRIGHT + Fore.WHITE + "[" + Fore.RED + "-" +
Fore.RED + "-" + Fore.WHITE + "]" +
Fore.WHITE + "]" + Fore.GREEN + f" {self.result.site_name}:" +
Fore.GREEN + f" {self.result.site_name}:" + Fore.RED + f" {self.result.context}" +
Fore.RED + f" {self.result.context}" + Fore.YELLOW + f" ")
Fore.YELLOW + f" ")
else:
print(f"[-] {self.result.site_name}: {self.result.context} ")
elif result.status == QueryStatus.ILLEGAL: elif result.status == QueryStatus.ILLEGAL:
if self.print_all: if self.print_all:
msg = "Illegal Username Format For This Site!" msg = "Illegal Username Format For This Site!"
if self.color: print(Style.BRIGHT + Fore.WHITE + "[" +
print((Style.BRIGHT + Fore.WHITE + "[" + Fore.RED + "-" +
Fore.RED + "-" + Fore.WHITE + "]" +
Fore.WHITE + "]" + Fore.GREEN + f" {self.result.site_name}:" +
Fore.GREEN + f" {self.result.site_name}:" + Fore.YELLOW + f" {msg}")
Fore.YELLOW + f" {msg}"))
else:
print(f"[-] {self.result.site_name} {msg}")
else: else:
# It should be impossible to ever get here... # It should be impossible to ever get here...

Loading…
Cancel
Save