Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

black formatting #653

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Scripts/API/Cryptocurrency Converter/cryptozor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def __init__(self, currency, cryptocurrency):

def convert(self, amount):
api = requests.get(
"https://api.coinbase.com/v2/exchange-rates?currency=" + self.cryptocurrency
"https://api.coinbase.com/v2/exchange-rates?currency="
+ self.cryptocurrency
)
try:
currentPrice = api.json()["data"]["rates"][self.currency]
Expand Down
46 changes: 23 additions & 23 deletions Scripts/API/Football-Standings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
LEAGUE_CODE = {
"BSA": {"code": 2013, "name": "Brazilian First Division"},
"BL": {"code": 2002, "name": "Bundesliga"}, # Bundesliga
"ECL": {"code": 2016, "name": "English Championship"}, # English Championship
"ECL": {
"code": 2016,
"name": "English Championship",
}, # English Championship
"ERD": {"code": 2003, "name": "Eredivisie"}, # Eredivisie [Dutch]
"L1": {"code": 2015, "name": "Ligue 1"}, # Ligue 1
"SPA": {"code": 2014, "name": "La Liga"}, # La Liga
Expand Down Expand Up @@ -42,32 +45,27 @@ def print_standings(league_id):
+ str(obj["season"]["currentMatchday"])
+ "\n"
)
str_re += (
"╔════╤════════════════════════════════════╤════╤════╤════╤════╤═════╤═════╗\n"
)
str_re += (
"║ SN │ TEAM │ M │ W │ D │ L │ PTS │ GD ║\n"
)
str_re += (
"╠════╪════════════════════════════════════╪════╪════╪════╪════╪═════╪═════╣\n"
)
str_re += "╔════╤════════════════════════════════════╤════╤════╤════╤════╤═════╤═════╗\n"
str_re += "║ SN │ TEAM │ M │ W │ D │ L │ PTS │ GD ║\n"
str_re += "╠════╪════════════════════════════════════╪════╪════╪════╪════╪═════╪═════╣\n"
for team in obj["standings"][0]["table"]:
text = "║ %-2d │ %-34s │ %-2d │ %-2d │ %-2d │ %-2d │ %-3d │ %+-3d ║\n" % (
team["position"],
team["team"]["name"][:34],
team["playedGames"],
team["won"],
team["draw"],
team["lost"],
team["points"],
team["goalDifference"],
text = (
"║ %-2d │ %-34s │ %-2d │ %-2d │ %-2d │ %-2d │ %-3d │ %+-3d ║\n"
% (
team["position"],
team["team"]["name"][:34],
team["playedGames"],
team["won"],
team["draw"],
team["lost"],
team["points"],
team["goalDifference"],
)
)

str_re += text

str_re += (
"╚════╧════════════════════════════════════╧════╧════╧════╧════╧═════╧═════╝"
)
str_re += "╚════╧════════════════════════════════════╧════╧════╧════╧════╧═════╧═════╝"

print(str_re)

Expand All @@ -88,7 +86,9 @@ def print_standings(league_id):
if arg in ["--help", "-h"]:
print("List of leagues and the codes: ")
for sno, key in enumerate(LEAGUE_CODE.keys()):
print("%2d. %-30s %s" % (sno + 1, LEAGUE_CODE[key]["name"], key))
print(
"%2d. %-30s %s" % (sno + 1, LEAGUE_CODE[key]["name"], key)
)
sys.exit(0)

league_id = LEAGUE_CODE.get(arg)
Expand Down
10 changes: 9 additions & 1 deletion Scripts/API/GeoCode API/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@

where.write("myData = [\n")
for item in adrs:
st = "[" + str(item[0]) + ", " + str(item[1]) + ", '" + str(item[2]) + "' ], \n"
st = (
"["
+ str(item[0])
+ ", "
+ str(item[1])
+ ", '"
+ str(item[2])
+ "' ], \n"
)
where.write(st)
where.write(",\n")
where.write("];\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def create_and_share_sheet(user_mail, spreadsheet_name, csv_file):
required=True,
)
parser.add_argument(
"-csv", help="Enter path of csv file", dest="csv", type=str, required=True
"-csv",
help="Enter path of csv file",
dest="csv",
type=str,
required=True,
)
parser.add_argument(
"-spreadsheet_name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def get_sheet_json(spreadsheet_name, json_file):
description="get data from spreadsheet in json format"
)
parser.add_argument(
"-json", help="Enter path of json file", dest="json", type=str, required=True
"-json",
help="Enter path of json file",
dest="json",
type=str,
required=True,
)
parser.add_argument(
"-spreadsheet_name",
Expand Down
4 changes: 3 additions & 1 deletion Scripts/API/Random_Album_API/Random_Album_API/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
# Register the blueprint
app.register_blueprint(random_album)
# Add the route to the view class
app.add_url_rule("/v1/random-album/", view_func=RandomAlbumAPI.as_view("random-album"))
app.add_url_rule(
"/v1/random-album/", view_func=RandomAlbumAPI.as_view("random-album")
)

# Exception Handler
@app.errorhandler(APIException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def load_dataset(self):

def get_random_album(self):
"""Get a random album from dataset"""
self.__out = self.dataset.iloc[[random.randint(0, 499)]].to_dict("record")
self.__out = self.dataset.iloc[[random.randint(0, 499)]].to_dict(
"record"
)

def get_all_album(self):
"""In case if you want all the records"""
Expand Down
12 changes: 9 additions & 3 deletions Scripts/API/Random_Joke/joke.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
JOKE_TWO_PARTS = f"""{fg(40) + attr("bold") + attr("dim")}Setup: {rst + fg(202)}{{setup}}
{fg(40) + attr("bold") + attr("dim")}Delivery: {rst + fg(202)}{{delivery}}"""

JOKE_SINGLE = f"""{fg(40) + attr("bold") + attr("dim")}Joke: {rst + fg(202)}{{joke}}"""
JOKE_SINGLE = (
f"""{fg(40) + attr("bold") + attr("dim")}Joke: {rst + fg(202)}{{joke}}"""
)

DEFAULT_FORMAT = f"""{fg(46) + attr("bold") + attr("dim")}Category: {rst + fg(214)}{{category}}
{fg(46) + attr("bold") + attr("dim")}Type: {rst + fg(214)}{{type}}
Expand Down Expand Up @@ -56,7 +58,9 @@ def main(category: str = "Any", exclude: str = ""):

if res["error"]:
print(
ERROR_MSG.format(error_message=rst + fg(9) + res["additionalInfo"]),
ERROR_MSG.format(
error_message=rst + fg(9) + res["additionalInfo"]
),
file=sys.stderr,
)
sys.exit(1)
Expand All @@ -66,7 +70,9 @@ def main(category: str = "Any", exclude: str = ""):
DEFAULT_FORMAT.format(
category=res["category"],
type=res["type"],
joke=JOKE_TWO_PARTS.format(setup=res["setup"], delivery=res["delivery"])
joke=JOKE_TWO_PARTS.format(
setup=res["setup"], delivery=res["delivery"]
)
if res["type"] == "twopart"
else JOKE_SINGLE.format(joke=res["joke"]),
)
Expand Down
4 changes: 3 additions & 1 deletion Scripts/API/twilio_sms/twilio_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

def send_message_phone(phone, body):
account_sid = "<YOUR ACCOUNT_SID>" # Replace this with your account sid
auth_token = "<YOUR AUTH_TOKEN>" # Replace this with your account Auth Token
auth_token = (
"<YOUR AUTH_TOKEN>" # Replace this with your account Auth Token
)
# Create a client object from Twilio Rest
client = Client(account_sid, auth_token)
retry_count = 0
Expand Down
4 changes: 3 additions & 1 deletion Scripts/Bots/DiscordBot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ async def clear(ctx, amount=5):


async def clear_error(ctx, error):
await ctx.send("Please specify the amount of messages to clear with tentacles")
await ctx.send(
"Please specify the amount of messages to clear with tentacles"
)


@client.command()
Expand Down
73 changes: 55 additions & 18 deletions Scripts/Bots/Instagram_Bot/Instagram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class InstaBot:
def __init__(self, username, pw):
path = pathlib.Path().absolute()
try:
self.driver = webdriver.Chrome(r"{}\{}".format(path, "chromedriver.exe"))
self.driver = webdriver.Chrome(
r"{}\{}".format(path, "chromedriver.exe")
)
except:
try:
self.driver = webdriver.Firefox(
Expand All @@ -32,12 +34,18 @@ def __init__(self, username, pw):
self.wait = WebDriverWait(self.driver, 10).until

self.wait(
EC.presence_of_element_located((By.XPATH, "//input[@name='username']"))
EC.presence_of_element_located(
(By.XPATH, "//input[@name='username']")
)
).send_keys(username)
self.driver.find_element_by_xpath("//input[@name='password']").send_keys(pw)
self.driver.find_element_by_xpath(
"//input[@name='password']"
).send_keys(pw)
self.driver.find_element_by_xpath('//button[@type="submit"]').click()
try:
self.driver.find_element_by_xpath("//input[@aria-label='Security Code']")
self.driver.find_element_by_xpath(
"//input[@aria-label='Security Code']"
)
print("\nEnter the otp and login to continue\n")
for _ in range(2):
WebDriverWait(self.driver, 50).until(
Expand Down Expand Up @@ -65,15 +73,23 @@ def get_unfollowers(self):
).click()
self.driver.find_element_by_xpath("//div[text()='Profile']").click()
self.wait(
EC.element_to_be_clickable((By.XPATH, "//a[contains(@href,'/following')]"))
EC.element_to_be_clickable(
(By.XPATH, "//a[contains(@href,'/following')]")
)
).click()
following = self._get_names()
self.wait(
EC.element_to_be_clickable((By.XPATH, "//a[contains(@href,'/followers')]"))
EC.element_to_be_clickable(
(By.XPATH, "//a[contains(@href,'/followers')]")
)
).click()
followers = self._get_names()
not_following_back = [user for user in following if user not in followers]
you_not_following_back = [user for user in followers if user not in following]
not_following_back = [
user for user in following if user not in followers
]
you_not_following_back = [
user for user in followers if user not in following
]
self.driver.find_element_by_xpath("//img[@alt='Instagram']").click()

with open("Not Following Back", "w") as f1:
Expand All @@ -84,7 +100,9 @@ def get_unfollowers(self):
self.driver.minimize_window()

print(
"People who aren't following back ({}) :\n".format(len(not_following_back))
"People who aren't following back ({}) :\n".format(
len(not_following_back)
)
)
print("\n".join(not_following_back))
print("\n\nDo you want to UNFOLLOW them all??")
Expand Down Expand Up @@ -142,14 +160,21 @@ def unfollow(self, not_following_back):
)
).click()
self.wait(
EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='Search']"))
EC.element_to_be_clickable(
(By.XPATH, "//input[@placeholder='Search']")
)
).click()
self.wait(
EC.element_to_be_clickable((By.XPATH, "//a[@href='/{}/']".format(i)))
EC.element_to_be_clickable(
(By.XPATH, "//a[@href='/{}/']".format(i))
)
).click()
self.wait(
EC.element_to_be_clickable(
(By.XPATH, "//span[@class='glyphsSpriteFriend_Follow u-__7']")
(
By.XPATH,
"//span[@class='glyphsSpriteFriend_Follow u-__7']",
)
)
).click()
sleep(1)
Expand All @@ -175,7 +200,9 @@ def follow_back(self, you_not_following_back):
"//input[@placeholder='Search']"
).send_keys(i)
self.wait(
EC.element_to_be_clickable((By.XPATH, "//a[@href='/{}/']".format(i)))
EC.element_to_be_clickable(
(By.XPATH, "//a[@href='/{}/']".format(i))
)
).click()
self.wait(
EC.element_to_be_clickable(
Expand Down Expand Up @@ -205,7 +232,9 @@ def spamming(self):
"//input[@placeholder='Search']"
).send_keys(i)
self.wait(
EC.presence_of_element_located((By.XPATH, "//a[@class='yCE8d ']"))
EC.presence_of_element_located(
(By.XPATH, "//a[@class='yCE8d ']")
)
).click()
self.wait(
EC.element_to_be_clickable(
Expand All @@ -232,7 +261,9 @@ def spamming(self):
def log_out(self):
self.driver.find_element_by_xpath("//img[@alt='Instagram']").click()
self.wait(
EC.element_to_be_clickable((By.XPATH, "//span[@class='_2dbep qNELH']"))
EC.element_to_be_clickable(
(By.XPATH, "//span[@class='_2dbep qNELH']")
)
).click()
log_out = "/html/body/div[1]/section/nav/div[2]/div/div/div[3]/div/div[5]/div[2]/div/div[2]/div[2]/div/div/div/div/div/div/div"
self.wait(EC.element_to_be_clickable((By.XPATH, log_out))).click()
Expand Down Expand Up @@ -290,7 +321,9 @@ def check_user(self):
decrypted = Fernet(key).decrypt(
(str(data[i + 1])[0:-1].strip()).encode()
)
self.users[str(data[i])[0:-1].strip()] = str(decrypted.decode())
self.users[str(data[i])[0:-1].strip()] = str(
decrypted.decode()
)
else:
return 0

Expand All @@ -316,7 +349,9 @@ def start_cmd(self):
a = int(input(" :- ").strip())
try:
if a == 1:
print("\n----Please wait, this command will take several seconds----\n")
print(
"\n----Please wait, this command will take several seconds----\n"
)
self.bot.get_unfollowers()
elif a == 2:
self.bot.spamming()
Expand All @@ -339,7 +374,9 @@ def add_user():
for i in range(a):
username = input("Enter username {}: ".format(i + 1))
f.write(username + "\n")
password = input("Enter password of username( {} ): ".format(username))
password = input(
"Enter password of username( {} ): ".format(username)
)
encrypted = Fernet(key).encrypt(password.encode())
f.write(encrypted.decode() + "\n")
Users().check_user()
Expand Down
4 changes: 3 additions & 1 deletion Scripts/Bots/Telegram_Weather_Bot/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def make_reply(message):
reply = []
reply.append(stats["name"])
reply.append(f"Description: {stats['weather'][0]['description']}")
reply.append(f"Temperature(celcius): {round(stats['main']['temp'] - 273.15, 2)}")
reply.append(
f"Temperature(celcius): {round(stats['main']['temp'] - 273.15, 2)}"
)
reply.append(
f"Max Temperature(celcius): {round(stats['main']['temp_max'] - 273.15, 2)}"
)
Expand Down
4 changes: 1 addition & 3 deletions Scripts/Bots/Telegram_Weather_Bot/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
class weather_info:
def __init__(self, config):
self.token = self.read_config(config)
self.base = (
f"https://api.openweathermap.org/data/2.5/weather?appid={self.token}"
)
self.base = f"https://api.openweathermap.org/data/2.5/weather?appid={self.token}"

def get_info(self, city):
url = self.base + f"&q={city}"
Expand Down
4 changes: 3 additions & 1 deletion Scripts/Bots/Torrent-Search-Bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def help(update, context):
If Any Issues Contact : @Apex-code

"""
context.bot.send_message(chat_id=update.effective_chat.id, text=helpmessage)
context.bot.send_message(
chat_id=update.effective_chat.id, text=helpmessage
)


def donate(update, context):
Expand Down
Loading