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

Commit f1095d8

Browse files
authored
Merge pull request #653 from Python-World/cleanup/black_formatting
black formatting
2 parents 8d8b4fb + c70e5f3 commit f1095d8

File tree

89 files changed

+1095
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1095
-394
lines changed

Scripts/API/Cryptocurrency Converter/cryptozor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def __init__(self, currency, cryptocurrency):
88

99
def convert(self, amount):
1010
api = requests.get(
11-
"https://api.coinbase.com/v2/exchange-rates?currency=" + self.cryptocurrency
11+
"https://api.coinbase.com/v2/exchange-rates?currency="
12+
+ self.cryptocurrency
1213
)
1314
try:
1415
currentPrice = api.json()["data"]["rates"][self.currency]

Scripts/API/Football-Standings/main.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
LEAGUE_CODE = {
1010
"BSA": {"code": 2013, "name": "Brazilian First Division"},
1111
"BL": {"code": 2002, "name": "Bundesliga"}, # Bundesliga
12-
"ECL": {"code": 2016, "name": "English Championship"}, # English Championship
12+
"ECL": {
13+
"code": 2016,
14+
"name": "English Championship",
15+
}, # English Championship
1316
"ERD": {"code": 2003, "name": "Eredivisie"}, # Eredivisie [Dutch]
1417
"L1": {"code": 2015, "name": "Ligue 1"}, # Ligue 1
1518
"SPA": {"code": 2014, "name": "La Liga"}, # La Liga
@@ -42,32 +45,27 @@ def print_standings(league_id):
4245
+ str(obj["season"]["currentMatchday"])
4346
+ "\n"
4447
)
45-
str_re += (
46-
"╔════╤════════════════════════════════════╤════╤════╤════╤════╤═════╤═════╗\n"
47-
)
48-
str_re += (
49-
"║ SN │ TEAM │ M │ W │ D │ L │ PTS │ GD ║\n"
50-
)
51-
str_re += (
52-
"╠════╪════════════════════════════════════╪════╪════╪════╪════╪═════╪═════╣\n"
53-
)
48+
str_re += "╔════╤════════════════════════════════════╤════╤════╤════╤════╤═════╤═════╗\n"
49+
str_re += "║ SN │ TEAM │ M │ W │ D │ L │ PTS │ GD ║\n"
50+
str_re += "╠════╪════════════════════════════════════╪════╪════╪════╪════╪═════╪═════╣\n"
5451
for team in obj["standings"][0]["table"]:
55-
text = "║ %-2d │ %-34s │ %-2d │ %-2d │ %-2d │ %-2d │ %-3d │ %+-3d ║\n" % (
56-
team["position"],
57-
team["team"]["name"][:34],
58-
team["playedGames"],
59-
team["won"],
60-
team["draw"],
61-
team["lost"],
62-
team["points"],
63-
team["goalDifference"],
52+
text = (
53+
"║ %-2d │ %-34s │ %-2d │ %-2d │ %-2d │ %-2d │ %-3d │ %+-3d ║\n"
54+
% (
55+
team["position"],
56+
team["team"]["name"][:34],
57+
team["playedGames"],
58+
team["won"],
59+
team["draw"],
60+
team["lost"],
61+
team["points"],
62+
team["goalDifference"],
63+
)
6464
)
6565

6666
str_re += text
6767

68-
str_re += (
69-
"╚════╧════════════════════════════════════╧════╧════╧════╧════╧═════╧═════╝"
70-
)
68+
str_re += "╚════╧════════════════════════════════════╧════╧════╧════╧════╧═════╧═════╝"
7169

7270
print(str_re)
7371

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

9494
league_id = LEAGUE_CODE.get(arg)

Scripts/API/GeoCode API/code.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@
5151

5252
where.write("myData = [\n")
5353
for item in adrs:
54-
st = "[" + str(item[0]) + ", " + str(item[1]) + ", '" + str(item[2]) + "' ], \n"
54+
st = (
55+
"["
56+
+ str(item[0])
57+
+ ", "
58+
+ str(item[1])
59+
+ ", '"
60+
+ str(item[2])
61+
+ "' ], \n"
62+
)
5563
where.write(st)
5664
where.write(",\n")
5765
where.write("];\n")

Scripts/API/Google-spreadsheet-share-and-retrieve/create_sheet.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def create_and_share_sheet(user_mail, spreadsheet_name, csv_file):
7171
required=True,
7272
)
7373
parser.add_argument(
74-
"-csv", help="Enter path of csv file", dest="csv", type=str, required=True
74+
"-csv",
75+
help="Enter path of csv file",
76+
dest="csv",
77+
type=str,
78+
required=True,
7579
)
7680
parser.add_argument(
7781
"-spreadsheet_name",

Scripts/API/Google-spreadsheet-share-and-retrieve/get_sheet.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ def get_sheet_json(spreadsheet_name, json_file):
3636
description="get data from spreadsheet in json format"
3737
)
3838
parser.add_argument(
39-
"-json", help="Enter path of json file", dest="json", type=str, required=True
39+
"-json",
40+
help="Enter path of json file",
41+
dest="json",
42+
type=str,
43+
required=True,
4044
)
4145
parser.add_argument(
4246
"-spreadsheet_name",

Scripts/API/Random_Album_API/Random_Album_API/application.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
# Register the blueprint
77
app.register_blueprint(random_album)
88
# Add the route to the view class
9-
app.add_url_rule("/v1/random-album/", view_func=RandomAlbumAPI.as_view("random-album"))
9+
app.add_url_rule(
10+
"/v1/random-album/", view_func=RandomAlbumAPI.as_view("random-album")
11+
)
1012

1113
# Exception Handler
1214
@app.errorhandler(APIException)

Scripts/API/Random_Album_API/Random_Album_API/logics/app_logic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ def load_dataset(self):
1919

2020
def get_random_album(self):
2121
"""Get a random album from dataset"""
22-
self.__out = self.dataset.iloc[[random.randint(0, 499)]].to_dict("record")
22+
self.__out = self.dataset.iloc[[random.randint(0, 499)]].to_dict(
23+
"record"
24+
)
2325

2426
def get_all_album(self):
2527
"""In case if you want all the records"""

Scripts/API/Random_Joke/joke.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
JOKE_TWO_PARTS = f"""{fg(40) + attr("bold") + attr("dim")}Setup: {rst + fg(202)}{{setup}}
1212
{fg(40) + attr("bold") + attr("dim")}Delivery: {rst + fg(202)}{{delivery}}"""
1313

14-
JOKE_SINGLE = f"""{fg(40) + attr("bold") + attr("dim")}Joke: {rst + fg(202)}{{joke}}"""
14+
JOKE_SINGLE = (
15+
f"""{fg(40) + attr("bold") + attr("dim")}Joke: {rst + fg(202)}{{joke}}"""
16+
)
1517

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

5759
if res["error"]:
5860
print(
59-
ERROR_MSG.format(error_message=rst + fg(9) + res["additionalInfo"]),
61+
ERROR_MSG.format(
62+
error_message=rst + fg(9) + res["additionalInfo"]
63+
),
6064
file=sys.stderr,
6165
)
6266
sys.exit(1)
@@ -66,7 +70,9 @@ def main(category: str = "Any", exclude: str = ""):
6670
DEFAULT_FORMAT.format(
6771
category=res["category"],
6872
type=res["type"],
69-
joke=JOKE_TWO_PARTS.format(setup=res["setup"], delivery=res["delivery"])
73+
joke=JOKE_TWO_PARTS.format(
74+
setup=res["setup"], delivery=res["delivery"]
75+
)
7076
if res["type"] == "twopart"
7177
else JOKE_SINGLE.format(joke=res["joke"]),
7278
)

Scripts/API/twilio_sms/twilio_sms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
def send_message_phone(phone, body):
88
account_sid = "<YOUR ACCOUNT_SID>" # Replace this with your account sid
9-
auth_token = "<YOUR AUTH_TOKEN>" # Replace this with your account Auth Token
9+
auth_token = (
10+
"<YOUR AUTH_TOKEN>" # Replace this with your account Auth Token
11+
)
1012
# Create a client object from Twilio Rest
1113
client = Client(account_sid, auth_token)
1214
retry_count = 0

Scripts/Bots/DiscordBot/bot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ async def clear(ctx, amount=5):
9292

9393

9494
async def clear_error(ctx, error):
95-
await ctx.send("Please specify the amount of messages to clear with tentacles")
95+
await ctx.send(
96+
"Please specify the amount of messages to clear with tentacles"
97+
)
9698

9799

98100
@client.command()

Scripts/Bots/Instagram_Bot/Instagram_bot.py

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ class InstaBot:
1111
def __init__(self, username, pw):
1212
path = pathlib.Path().absolute()
1313
try:
14-
self.driver = webdriver.Chrome(r"{}\{}".format(path, "chromedriver.exe"))
14+
self.driver = webdriver.Chrome(
15+
r"{}\{}".format(path, "chromedriver.exe")
16+
)
1517
except:
1618
try:
1719
self.driver = webdriver.Firefox(
@@ -32,12 +34,18 @@ def __init__(self, username, pw):
3234
self.wait = WebDriverWait(self.driver, 10).until
3335

3436
self.wait(
35-
EC.presence_of_element_located((By.XPATH, "//input[@name='username']"))
37+
EC.presence_of_element_located(
38+
(By.XPATH, "//input[@name='username']")
39+
)
3640
).send_keys(username)
37-
self.driver.find_element_by_xpath("//input[@name='password']").send_keys(pw)
41+
self.driver.find_element_by_xpath(
42+
"//input[@name='password']"
43+
).send_keys(pw)
3844
self.driver.find_element_by_xpath('//button[@type="submit"]').click()
3945
try:
40-
self.driver.find_element_by_xpath("//input[@aria-label='Security Code']")
46+
self.driver.find_element_by_xpath(
47+
"//input[@aria-label='Security Code']"
48+
)
4149
print("\nEnter the otp and login to continue\n")
4250
for _ in range(2):
4351
WebDriverWait(self.driver, 50).until(
@@ -65,15 +73,23 @@ def get_unfollowers(self):
6573
).click()
6674
self.driver.find_element_by_xpath("//div[text()='Profile']").click()
6775
self.wait(
68-
EC.element_to_be_clickable((By.XPATH, "//a[contains(@href,'/following')]"))
76+
EC.element_to_be_clickable(
77+
(By.XPATH, "//a[contains(@href,'/following')]")
78+
)
6979
).click()
7080
following = self._get_names()
7181
self.wait(
72-
EC.element_to_be_clickable((By.XPATH, "//a[contains(@href,'/followers')]"))
82+
EC.element_to_be_clickable(
83+
(By.XPATH, "//a[contains(@href,'/followers')]")
84+
)
7385
).click()
7486
followers = self._get_names()
75-
not_following_back = [user for user in following if user not in followers]
76-
you_not_following_back = [user for user in followers if user not in following]
87+
not_following_back = [
88+
user for user in following if user not in followers
89+
]
90+
you_not_following_back = [
91+
user for user in followers if user not in following
92+
]
7793
self.driver.find_element_by_xpath("//img[@alt='Instagram']").click()
7894

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

86102
print(
87-
"People who aren't following back ({}) :\n".format(len(not_following_back))
103+
"People who aren't following back ({}) :\n".format(
104+
len(not_following_back)
105+
)
88106
)
89107
print("\n".join(not_following_back))
90108
print("\n\nDo you want to UNFOLLOW them all??")
@@ -142,14 +160,21 @@ def unfollow(self, not_following_back):
142160
)
143161
).click()
144162
self.wait(
145-
EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='Search']"))
163+
EC.element_to_be_clickable(
164+
(By.XPATH, "//input[@placeholder='Search']")
165+
)
146166
).click()
147167
self.wait(
148-
EC.element_to_be_clickable((By.XPATH, "//a[@href='/{}/']".format(i)))
168+
EC.element_to_be_clickable(
169+
(By.XPATH, "//a[@href='/{}/']".format(i))
170+
)
149171
).click()
150172
self.wait(
151173
EC.element_to_be_clickable(
152-
(By.XPATH, "//span[@class='glyphsSpriteFriend_Follow u-__7']")
174+
(
175+
By.XPATH,
176+
"//span[@class='glyphsSpriteFriend_Follow u-__7']",
177+
)
153178
)
154179
).click()
155180
sleep(1)
@@ -175,7 +200,9 @@ def follow_back(self, you_not_following_back):
175200
"//input[@placeholder='Search']"
176201
).send_keys(i)
177202
self.wait(
178-
EC.element_to_be_clickable((By.XPATH, "//a[@href='/{}/']".format(i)))
203+
EC.element_to_be_clickable(
204+
(By.XPATH, "//a[@href='/{}/']".format(i))
205+
)
179206
).click()
180207
self.wait(
181208
EC.element_to_be_clickable(
@@ -205,7 +232,9 @@ def spamming(self):
205232
"//input[@placeholder='Search']"
206233
).send_keys(i)
207234
self.wait(
208-
EC.presence_of_element_located((By.XPATH, "//a[@class='yCE8d ']"))
235+
EC.presence_of_element_located(
236+
(By.XPATH, "//a[@class='yCE8d ']")
237+
)
209238
).click()
210239
self.wait(
211240
EC.element_to_be_clickable(
@@ -232,7 +261,9 @@ def spamming(self):
232261
def log_out(self):
233262
self.driver.find_element_by_xpath("//img[@alt='Instagram']").click()
234263
self.wait(
235-
EC.element_to_be_clickable((By.XPATH, "//span[@class='_2dbep qNELH']"))
264+
EC.element_to_be_clickable(
265+
(By.XPATH, "//span[@class='_2dbep qNELH']")
266+
)
236267
).click()
237268
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"
238269
self.wait(EC.element_to_be_clickable((By.XPATH, log_out))).click()
@@ -290,7 +321,9 @@ def check_user(self):
290321
decrypted = Fernet(key).decrypt(
291322
(str(data[i + 1])[0:-1].strip()).encode()
292323
)
293-
self.users[str(data[i])[0:-1].strip()] = str(decrypted.decode())
324+
self.users[str(data[i])[0:-1].strip()] = str(
325+
decrypted.decode()
326+
)
294327
else:
295328
return 0
296329

@@ -316,7 +349,9 @@ def start_cmd(self):
316349
a = int(input(" :- ").strip())
317350
try:
318351
if a == 1:
319-
print("\n----Please wait, this command will take several seconds----\n")
352+
print(
353+
"\n----Please wait, this command will take several seconds----\n"
354+
)
320355
self.bot.get_unfollowers()
321356
elif a == 2:
322357
self.bot.spamming()
@@ -339,7 +374,9 @@ def add_user():
339374
for i in range(a):
340375
username = input("Enter username {}: ".format(i + 1))
341376
f.write(username + "\n")
342-
password = input("Enter password of username( {} ): ".format(username))
377+
password = input(
378+
"Enter password of username( {} ): ".format(username)
379+
)
343380
encrypted = Fernet(key).encrypt(password.encode())
344381
f.write(encrypted.decode() + "\n")
345382
Users().check_user()

Scripts/Bots/Telegram_Weather_Bot/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def make_reply(message):
1717
reply = []
1818
reply.append(stats["name"])
1919
reply.append(f"Description: {stats['weather'][0]['description']}")
20-
reply.append(f"Temperature(celcius): {round(stats['main']['temp'] - 273.15, 2)}")
20+
reply.append(
21+
f"Temperature(celcius): {round(stats['main']['temp'] - 273.15, 2)}"
22+
)
2123
reply.append(
2224
f"Max Temperature(celcius): {round(stats['main']['temp_max'] - 273.15, 2)}"
2325
)

Scripts/Bots/Telegram_Weather_Bot/weather.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
class weather_info:
77
def __init__(self, config):
88
self.token = self.read_config(config)
9-
self.base = (
10-
f"https://api.openweathermap.org/data/2.5/weather?appid={self.token}"
11-
)
9+
self.base = f"https://api.openweathermap.org/data/2.5/weather?appid={self.token}"
1210

1311
def get_info(self, city):
1412
url = self.base + f"&q={city}"

Scripts/Bots/Torrent-Search-Bot/bot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def help(update, context):
8585
If Any Issues Contact : @Apex-code
8686
8787
"""
88-
context.bot.send_message(chat_id=update.effective_chat.id, text=helpmessage)
88+
context.bot.send_message(
89+
chat_id=update.effective_chat.id, text=helpmessage
90+
)
8991

9092

9193
def donate(update, context):

0 commit comments

Comments
 (0)