Merge pull request #1686 from sherlock-project/code-clean-up

Cleaned code to suite flake8's specifications
pull/1687/head
Siddharth Dushantha 2 years ago committed by GitHub
commit 5eb05ce265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,10 @@ results of queries.
from result import QueryStatus from result import QueryStatus
from colorama import Fore, Style from colorama import Fore, Style
import webbrowser import webbrowser
globvar = 0 # global variable to count the number of results.
# Global variable to count the number of results.
globvar = 0
class QueryNotify: class QueryNotify:
"""Query Notify Object. """Query Notify Object.
@ -104,6 +107,7 @@ class QueryNotify:
""" """
return str(self.result) return str(self.result)
class QueryNotifyPrint(QueryNotify): class QueryNotifyPrint(QueryNotify):
"""Query Notify Print Object. """Query Notify Print Object.
@ -161,32 +165,6 @@ class QueryNotifyPrint(QueryNotify):
return return
def finish(self, message="The processing has been finished."):
"""Notify Start.
Will print the last line to the standard output.
Keyword Arguments:
self -- This object.
message -- The last phrase.
Return Value:
Nothing.
"""
title = "End"
print('\r') # An empty line between last line of main output and last line(more clear output)
print(Style.BRIGHT + Fore.GREEN + "[" +
Fore.YELLOW + "!" +
Fore.GREEN + f"] {title}" +
Fore.GREEN + ": " +
Fore.WHITE + f" {message}" )
# An empty line between first line and the result(more clear output)
# return
def countResults(self): def countResults(self):
"""This function counts the number of results. Every time the function is called, """This function counts the number of results. Every time the function is called,
the number of results is increasing. the number of results is increasing.
@ -217,7 +195,7 @@ class QueryNotifyPrint(QueryNotify):
self.result = result self.result = result
response_time_text = "" response_time_text = ""
if self.result.query_time is not None and self.verbose == True: if self.result.query_time is not None and self.verbose is True:
response_time_text = f" [{round(self.result.query_time * 1000)}ms]" response_time_text = f" [{round(self.result.query_time * 1000)}ms]"
# Output to the terminal is desired. # Output to the terminal is desired.
@ -250,7 +228,7 @@ class QueryNotifyPrint(QueryNotify):
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 + " ")
elif result.status == QueryStatus.ILLEGAL: elif result.status == QueryStatus.ILLEGAL:
if self.print_all: if self.print_all:
@ -289,15 +267,14 @@ class QueryNotifyPrint(QueryNotify):
title = "End" title = "End"
print('\r') # An empty line between last line of main output and last line(more clear output) # An empty line between last line of main output and last line(more clear output)
print('\r')
print(Style.BRIGHT + Fore.GREEN + "[" + print(Style.BRIGHT + Fore.GREEN + "[" +
Fore.YELLOW + "!" + Fore.YELLOW + "!" +
Fore.GREEN + f"] {title}" + Fore.GREEN + f"] {title}" +
Fore.GREEN + ": " + Fore.GREEN + ": " +
Fore.WHITE + f" {message}") Fore.WHITE + f" {message}")
# An empty line between first line and the result(more clear output)
return return
def __str__(self): def __str__(self):

@ -747,10 +747,7 @@ def main():
http_status = [] http_status = []
response_time_s = [] response_time_s = []
for site in results: for site in results:
if response_time_s is None: if response_time_s is None:
response_time_s.append("") response_time_s.append("")
else: else:
@ -765,8 +762,6 @@ def main():
DataFrame = pd.DataFrame({"username": usernames, "name": names, "url_main": url_main, "url_user": url_user, "exists": exists, "http_status": http_status, "response_time_s": response_time_s}) DataFrame = pd.DataFrame({"username": usernames, "name": names, "url_main": url_main, "url_user": url_user, "exists": exists, "http_status": http_status, "response_time_s": response_time_s})
DataFrame.to_excel(f'{username}.xlsx', sheet_name='sheet1', index=False) DataFrame.to_excel(f'{username}.xlsx', sheet_name='sheet1', index=False)
print() print()
query_notify.finish() query_notify.finish()

@ -3,9 +3,9 @@
This module contains various tests. This module contains various tests.
""" """
from tests.base import SherlockBaseTest from tests.base import SherlockBaseTest
import unittest
import secrets import secrets
class SherlockDetectTests(SherlockBaseTest): class SherlockDetectTests(SherlockBaseTest):
def test_detect_true_via_message(self): def test_detect_true_via_message(self):
"""Test Username Does Exist (Via Message). """Test Username Does Exist (Via Message).
@ -116,7 +116,6 @@ class SherlockDetectTests(SherlockBaseTest):
return return
class SherlockSiteCoverageTests(SherlockBaseTest): class SherlockSiteCoverageTests(SherlockBaseTest):
def test_coverage_false_via_response_url(self): def test_coverage_false_via_response_url(self):
"""Test Username Does Not Exist Site Coverage (Via Response URL). """Test Username Does Not Exist Site Coverage (Via Response URL).

Loading…
Cancel
Save