Patch: Style fixes

This commit is contained in:
PS Narayanan 2021-10-10 22:18:32 +05:30
parent cac389a7f7
commit cc156037b4
8 changed files with 90 additions and 8 deletions

2
.flake8 Normal file
View File

@ -0,0 +1,2 @@
[flake8]
max-line-length = 119

66
.style.yapf Normal file
View File

@ -0,0 +1,66 @@
[style]
based_on_style=pep8
# The column limit.
column_limit=119
# Align closing bracket with visual indentation.
align_closing_bracket_with_visual_indent=False
allow_split_before_dict_value = False
# Put closing brackets on a separate line, dedented, if the bracketed
# expression can't fit in a single line. Applies to all kinds of brackets,
# including function definitions and calls. For example:
#
# config = {
# 'key1': 'value1',
# 'key2': 'value2',
# } # <--- this bracket is dedented and on a separate line
#
# time_series = self.remote_client.query_entity_counters(
# entity='dev3246.region1',
# key='dns.query_latency_tcp',
# transform=Transformation.AVERAGE(window=timedelta(seconds=60)),
# start_ts=now()-timedelta(days=3),
# end_ts=now(),
# ) # <--- this bracket is dedented and on a separate line
dedent_closing_brackets=True
# Insert a space between the ending comma and closing bracket of a list,
# etc.
space_between_ending_comma_and_closing_bracket=False
# Split after the opening parenthesis which surrounds an expression if it doesn't
# fit on a single line.
split_before_expression_after_opening_paren=True
# Set to True to split list comprehensions and generators that have
# non-trivial expressions and multiple clauses before each of these
# clauses. For example:
#
# result = [
# a_long_var + 100 for a_long_var in xrange(1000)
# if a_long_var % 10]
#
# would reformat to something like:
#
# result = [
# a_long_var + 100
# for a_long_var in xrange(1000)
# if a_long_var % 10]
split_complex_comprehension=True
# Insert a blank line before a 'def' or 'class' immediately nested
# within another 'def' or 'class'. For example:
#
# class Foo:
# # <------ this blank line
# def method():
# ...
blank_line_before_nested_class_or_def=True
# The i18n function call names. The presence of this function stops
# reformatting on that line, because the string it has cannot be moved
# away from the i18n comment.
i18n_function_call=['_']

14
poetry.lock generated
View File

@ -418,6 +418,14 @@ six = ">=1.4.0"
[package.extras]
test = ["pytest (>=2.2.3)", "flake8 (>=2.4.0)", "isort (>=4.2.2)"]
[[package]]
name = "yapf"
version = "0.31.0"
description = "A formatter for Python code."
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "yattag"
version = "1.14.0"
@ -441,7 +449,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pyt
[metadata]
lock-version = "1.1"
python-versions = "^3.7"
content-hash = "e12259fe6d0893a5541a7f0df9949e1b6e33417a237cefa3fee7236af206ab23"
content-hash = "bb2b9eb9d7a7bfdc3555e76f8ad44fa6d4b9d7c5009de6a2a4b72120a2b405bc"
[metadata.files]
altgraph = [
@ -697,6 +705,10 @@ urllib3 = [
validators = [
{file = "validators-0.12.6.tar.gz", hash = "sha256:f6aca085caf9e13d5a0fd8ddb3afbea2541c0ca9477b1fb8098c797dd812ff64"},
]
yapf = [
{file = "yapf-0.31.0-py2.py3-none-any.whl", hash = "sha256:e3a234ba8455fe201eaa649cdac872d590089a18b661e39bbac7020978dd9c2e"},
{file = "yapf-0.31.0.tar.gz", hash = "sha256:408fb9a2b254c302f49db83c59f9aa0b4b0fd0ec25be3a5c51181327922ff63d"},
]
yattag = [
{file = "yattag-1.14.0.tar.gz", hash = "sha256:5731a31cb7452c0c6930dd1a284e0170b39eee959851a2aceb8d6af4134a5fa8"},
]

View File

@ -22,6 +22,7 @@ threadsafe = "^1.0.0"
progress = "^1.5.0"
numpy = "^1.20.2"
scikit-learn = "^0.24.2"
yapf = "^0.31.0"
[tool.poetry.dev-dependencies]
pytest = "^6.2.3"

View File

@ -4,10 +4,10 @@ Core settings for TorBot.
import os
from dotenv import load_dotenv
load_dotenv() # Loads environment variables from .env file
load_dotenv() # Loads environment variables from .env file
__version__ = '2.1.0'
HOST = os.getenv('HOST')
PORT = os.getenv('PORT')
PORT = os.getenv('PORT')

View File

@ -25,7 +25,7 @@ class GoTor:
url = f'http://{address}:{port}/tree?link={link}&depth={depth}'
resp = requests.get(url)
return resp.json()
@staticmethod
def get_ip(address='localhost', port='8081'):
@ -66,4 +66,4 @@ class GoTor:
"""
url = f'http://{address}:{port}/phone?link={link}'
resp = requests.get(url)
return resp.json()
return resp.json()

View File

@ -91,6 +91,7 @@ def print_emails(url):
pprint(email_list)
return email_list
def print_phones(url):
"""
Prints any phones found within the HTML content of this url.
@ -103,4 +104,4 @@ def print_phones(url):
"""
phone_list = GoTor.get_phone(url)
pprint(phone_list)
return phone_list
return phone_list

View File

@ -15,6 +15,7 @@ from modules.savefile import saveJson
from modules.info import execute_all
from modules.collect_data import collect_data
# TorBot CLI class
class TorBot:
@ -22,7 +23,6 @@ class TorBot:
self.__version__ = config.__version__
self.args = args
def get_header(self):
license_msg = color("LICENSE: GNU Public License v3", "red")
banner = r"""
@ -61,7 +61,7 @@ class TorBot:
if args.phone:
phone_json = link_io.print_phones(args.url)
if args.save:
saveJson('Phones', phone_json)
saveJson('Phones', phone_json)
# -s/--save
else:
node_json = link_io.print_json(args.url, args.depth)