Skip to content

Commit 63b7450

Browse files
Format code with autopep8
This commit fixes the style issues introduced in 5bfb399 according to the output from autopep8. Details: https://deepsource.io/gh/avinashkranjan/Amazing-Python-Scripts/transform/cde918ce-12ee-455a-a397-6e343a1a9f1b/
1 parent 5bfb399 commit 63b7450

File tree

144 files changed

+5576
-4865
lines changed

Some content is hidden

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

144 files changed

+5576
-4865
lines changed

AWS Management Scripts/AWS Automation Script for AWS endorsement management/awsLambda.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def lambda_handler(event, context):
88
instances = Ec2Instances(region_name)
99
deleted_counts = instances.delete_snapshots(1)
1010
instances.delete_available_volumes()
11-
print("deleted_counts for region " + str(region_name) + " is " + str(deleted_counts))
11+
print("deleted_counts for region " +
12+
str(region_name) + " is " + str(deleted_counts))
1213
instances.shutdown()
1314
print("For RDS")
1415
rds = Rds(region_name)

AWS Management Scripts/AWS Automation Script for AWS endorsement management/ec2.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
def get_delete_data(older_days):
77
delete_time = datetime.now(tz=timezone.utc) - timedelta(days=older_days)
8-
return delete_time;
8+
return delete_time
99

1010

1111
def is_ignore_shutdown(tags):
1212
for tag in tags:
1313
print("K " + str(tag['Key']) + " is " + str(tag['Value']))
1414
if str(tag['Key']) == 'excludepower' and str(tag['Value']) == 'true':
15-
print("Not stopping K " + str(tag['Key']) + " is " + str(tag['Value']))
15+
print("Not stopping K " +
16+
str(tag['Key']) + " is " + str(tag['Value']))
1617
return True
1718
return False
1819

AWS Management Scripts/AWS Automation Script for AWS endorsement management/rds.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def _delete_instance_snapshot(self, identifier):
3636
self.rds.delete_db_snapshot(DBSnapshotIdentifier=identifier)
3737

3838
def _delete_cluster_snapshot(self, identifier):
39-
self.rds.delete_db_cluster_snapshot(DBClusterSnapshotIdentifier=identifier)
39+
self.rds.delete_db_cluster_snapshot(
40+
DBClusterSnapshotIdentifier=identifier)
4041

4142
@staticmethod
4243
def _can_delete_instance(tags):
@@ -88,7 +89,8 @@ def _cleanup_snapshots_clusters(self):
8889
if self._can_delete_snapshot(tags) and self._is_older_snapshot(
8990
str(snapshot['SnapshotCreateTime']).split(" ")):
9091
try:
91-
self._delete_cluster_snapshot(snapshot['DBClusterSnapshotIdentifier'])
92+
self._delete_cluster_snapshot(
93+
snapshot['DBClusterSnapshotIdentifier'])
9294
except Exception as e:
9395
print(str(e))
9496

@@ -99,14 +101,16 @@ def _cleanup_snapshot_instance(self):
99101
if self._can_delete_snapshot(tags) and self._is_older_snapshot(
100102
str(snapshot['SnapshotCreateTime']).split(" ")):
101103
try:
102-
self._delete_instance_snapshot(snapshot['DBSnapshotIdentifier'])
104+
self._delete_instance_snapshot(
105+
snapshot['DBSnapshotIdentifier'])
103106
except Exception as e:
104107
print(str(e))
105108

106109
@staticmethod
107110
def _is_older_snapshot(snapshot_datetime):
108111
snapshot_date = snapshot_datetime[0].split("-")
109-
snapshot_date = datetime.date(int(snapshot_date[0]), int(snapshot_date[1]), int(snapshot_date[2]))
112+
snapshot_date = datetime.date(int(snapshot_date[0]), int(
113+
snapshot_date[1]), int(snapshot_date[2]))
110114
today = datetime.date.today()
111115
if abs(today - snapshot_date).days > 2:
112116
return True

Age-Calculator-GUI/age_calc_gui.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@
55
# initialized window
66
root = Tk()
77
root.geometry('280x300')
8-
root.resizable(0,0)
8+
root.resizable(0, 0)
99
root.title('Age Calculator')
1010
statement = Label(root)
1111

1212
# defining the function for calculating age
13+
14+
1315
def ageCalc():
1416
global statement
1517
statement.destroy()
1618
today = date.today()
17-
birthDate = date(int(yearEntry.get()), int(monthEntry.get()), int(dayEntry.get()))
19+
birthDate = date(int(yearEntry.get()), int(
20+
monthEntry.get()), int(dayEntry.get()))
1821
age = today.year - birthDate.year
1922
if today.month < birthDate.month or today.month == birthDate.month and today.day < birthDate.day:
2023
age -= 1
2124
statement = Label(text=f"{nameValue.get()}'s age is {age}.")
2225
statement.grid(row=6, column=1, pady=15)
2326

27+
2428
# creating a label for person's name to display
25-
l1 = Label(text = "Name: ")
29+
l1 = Label(text="Name: ")
2630
l1.grid(row=1, column=0)
2731
nameValue = StringVar()
2832

@@ -31,21 +35,21 @@ def ageCalc():
3135
nameEntry.grid(row=1, column=1, padx=10, pady=10)
3236

3337
# label for year in which user was born
34-
l2 = Label(text = "Year: ")
38+
l2 = Label(text="Year: ")
3539
l2.grid(row=2, column=0)
3640
yearValue = StringVar()
3741
yearEntry = Entry(root, textvariable=yearValue)
3842
yearEntry.grid(row=2, column=1, padx=10, pady=10)
3943

4044
# label for month in which user was born
41-
l3 = Label(text = "Month: ")
45+
l3 = Label(text="Month: ")
4246
l3.grid(row=3, column=0)
4347
monthValue = StringVar()
4448
monthEntry = Entry(root, textvariable=monthValue)
4549
monthEntry.grid(row=3, column=1, padx=10, pady=10)
4650

4751
# label for day/date on which user was born
48-
l4 = Label(text = "Day: ")
52+
l4 = Label(text="Day: ")
4953
l4.grid(row=4, column=0)
5054
dayValue = StringVar()
5155
dayEntry = Entry(root, textvariable=dayValue)

Air pollution prediction/CodeAP.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@
1111
iaqi = data['iaqi']
1212

1313

14-
1514
for i in iaqi.items():
16-
print(i[0],':',i[1]['v'])
17-
dew = iaqi.get('dew','Nil')
18-
no2 = iaqi.get('no2','Nil')
19-
o3 = iaqi.get('o3','Nil')
20-
so2 = iaqi.get('so2','Nil')
21-
pm10 = iaqi.get('pm10','Nil')
22-
pm25 = iaqi.get('pm25','Nil')
23-
24-
print(f'{city} AQI :',aqi,'\n')
15+
print(i[0], ':', i[1]['v'])
16+
dew = iaqi.get('dew', 'Nil')
17+
no2 = iaqi.get('no2', 'Nil')
18+
o3 = iaqi.get('o3', 'Nil')
19+
so2 = iaqi.get('so2', 'Nil')
20+
pm10 = iaqi.get('pm10', 'Nil')
21+
pm25 = iaqi.get('pm25', 'Nil')
22+
23+
print(f'{city} AQI :', aqi, '\n')
2524
print('Individual Air quality')
26-
print('Dew :',dew)
27-
print('no2 :',no2)
28-
print('Ozone :',o3)
29-
print('sulphur :',so2)
30-
print('pm10 :',so2)
31-
print('pm25 :',pm25)
25+
print('Dew :', dew)
26+
print('no2 :', no2)
27+
print('Ozone :', o3)
28+
print('sulphur :', so2)
29+
print('pm10 :', so2)
30+
print('pm25 :', pm25)
3231
pollutants = [i for i in iaqi]
3332
values = [i['v'] for i in iaqi.values()]
3433

@@ -39,8 +38,9 @@
3938
explode[mx] = 0.1
4039

4140
# Plot a pie chart
42-
plt.figure(figsize=(8,6))
43-
plt.pie(values, labels=pollutants,explode=explode,autopct='%1.1f%%', shadow=True)
41+
plt.figure(figsize=(8, 6))
42+
plt.pie(values, labels=pollutants, explode=explode,
43+
autopct='%1.1f%%', shadow=True)
4444

4545
plt.title('Air pollutants and their probable amount in atmosphere [kanpur]')
4646

Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import cv2
22

3-
src1= input("Enter the path of the image 1\n") #getting the path for first image
4-
src1 = cv2.imread(src1)
5-
#src1 = cv2.resize(src1,(540,540)) #resizing the image
6-
src2 = input("Enter the path of the image 2\n") #getting the path for second image
3+
# getting the path for first image
4+
src1 = input("Enter the path of the image 1\n")
5+
src1 = cv2.imread(src1)
6+
# src1 = cv2.resize(src1,(540,540)) #resizing the image
7+
# getting the path for second image
8+
src2 = input("Enter the path of the image 2\n")
79
src2 = cv2.imread(src2)
810

9-
src2 = cv2.resize(src2, src1.shape[1::-1]) #Resizing the image so that both images have same dimensions
10-
andop= cv2.bitwise_and(src1, src2,mask=None) #Applying Bitwise AND operation
11-
andop=cv2.resize(andop,(640,640))
12-
cv2.imshow('Bitwise AND',andop)
11+
# Resizing the image so that both images have same dimensions
12+
src2 = cv2.resize(src2, src1.shape[1::-1])
13+
# Applying Bitwise AND operation
14+
andop = cv2.bitwise_and(src1, src2, mask=None)
15+
andop = cv2.resize(andop, (640, 640))
16+
cv2.imshow('Bitwise AND', andop)
1317

14-
orop= cv2.bitwise_or(src1, src2,mask=None) #Applying Bitwise OR operation
15-
orop=cv2.resize(orop,(640,640))
16-
cv2.imshow('Bitwise OR',orop)
18+
orop = cv2.bitwise_or(src1, src2, mask=None) # Applying Bitwise OR operation
19+
orop = cv2.resize(orop, (640, 640))
20+
cv2.imshow('Bitwise OR', orop)
1721

18-
xorop = cv2.bitwise_xor(src1,src2,mask=None) #Applying Bitwise OR operation
19-
xorop=cv2.resize(xorop,(640,640))
20-
cv2.imshow('Bitwise XOR',xorop)
22+
xorop = cv2.bitwise_xor(src1, src2, mask=None) # Applying Bitwise OR operation
23+
xorop = cv2.resize(xorop, (640, 640))
24+
cv2.imshow('Bitwise XOR', xorop)
2125
cv2.waitKey(0)
2226
cv2.destroyAllWindows()

Attachment_Downloader/attachment.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,48 @@
11
import ezgmail
22

3+
34
def attachmentdownload(resulthreads):
45
# Two Objects used in code are GmailThread and GmailMessage
56
# 1. GmailThread - Represents conversation threads
67
# 2. GmailMessage - Represents individual emails within Threads
78
countofresults = len(resulthreads)
89
try:
910
for i in range(countofresults):
10-
if len(resulthreads[i].messages) > 1: # checks whether the count of messages in threads is greater than 1
11+
# checks whether the count of messages in threads is greater than 1
12+
if len(resulthreads[i].messages) > 1:
1113
for j in range(len(resulthreads[i].messages)):
1214
resulthreads[i].messages[
1315
j].downloadAllAttachments() # downloads attachment(s) for individual messages
1416
else:
15-
resulthreads[i].messages[0].downloadAllAttachments() # downloads attachment(s) for single message
17+
# downloads attachment(s) for single message
18+
resulthreads[i].messages[0].downloadAllAttachments()
1619
print("Download compelete. Please check your root directory.")
1720
except:
1821
raise Exception("Error occured while downloading attachment(s).")
1922

2023

2124
if __name__ == '__main__':
2225
query = input("Enter search query: ")
23-
newquery = query + " + has:attachment" # appending to make sure the result threads always has an attachment
24-
resulthreads = ezgmail.search(newquery) # search functions accepts all the operators described at https://support.google.com/mail/answer/7190?hl=en
26+
# appending to make sure the result threads always has an attachment
27+
newquery = query + " + has:attachment"
28+
# search functions accepts all the operators described at https://support.google.com/mail/answer/7190?hl=en
29+
resulthreads = ezgmail.search(newquery)
2530

2631
if len(resulthreads) == 0:
27-
print("Result has no attachments:") # Executed if results don't have attachment
32+
# Executed if results don't have attachment
33+
print("Result has no attachments:")
2834
else:
2935
print("Result(s) with attachments:")
3036
for threads in resulthreads:
31-
print(f"Email Subject: {threads.messages[0].subject}") # prints the subject line of email thread in results
37+
# prints the subject line of email thread in results
38+
print(f"Email Subject: {threads.messages[0].subject}")
3239
try:
3340
ask = input(
3441
"Do you want to download attachment(s) in result(s) (Yes/No)? ") # Allows user to decide whether they want to download attachment(s) or not
3542
if ask == "Yes":
36-
attachmentdownload(resulthreads) # calls the function that downloads attachment(s)
43+
# calls the function that downloads attachment(s)
44+
attachmentdownload(resulthreads)
3745
else:
3846
print("Program exited")
3947
except:
4048
print("Something went wrong")
41-
42-
43-
44-

Auto Birthday Wisher/Auto B'Day Wisher.py

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1-
import pandas as pd # Pandas library is used for importing and reading the data
2-
import datetime # datetime module is used for fetching the dates
1+
# Pandas library is used for importing and reading the data
2+
import pandas as pd
3+
# datetime module is used for fetching the dates
4+
import datetime
35
import smtplib # smtp library used for sending mail
46
import os
57

68
current_path = os.getcwd()
79
print(current_path)
8-
os.chdir(current_path) # Changing the Path of the directory in which you are currently working
10+
# Changing the Path of the directory in which you are currently working
11+
os.chdir(current_path)
912

10-
GMAIL_ID = input("Enter your email: ") # Give your mail here from which you want to send the wishes
11-
GMAIL_PSWD = input("Enter password for your email mentioned above: ") # Give your mail password
13+
# Give your mail here from which you want to send the wishes
14+
GMAIL_ID = input("Enter your email: ")
15+
# Give your mail password
16+
GMAIL_PSWD = input("Enter password for your email mentioned above: ")
1217

1318

1419
def sendEmail(to, sub, msg):
1520
print(f"Email to {to} sent: \nSubject: {sub} ,\nMessage: {msg}")
16-
s = smtplib.SMTP('smtp.gmail.com', 587) # creating server to send mail
17-
s.starttls() # start a TLS session
18-
s.login(GMAIL_ID, GMAIL_PSWD) # the function will login with your Gmail credentials
19-
s.sendmail(GMAIL_ID, to, f"Subject: {sub} \n\n {msg}") # sending the mail
21+
# creating server to send mail
22+
s = smtplib.SMTP('smtp.gmail.com', 587)
23+
# start a TLS session
24+
s.starttls()
25+
# the function will login with your Gmail credentials
26+
s.login(GMAIL_ID, GMAIL_PSWD)
27+
# sending the mail
28+
s.sendmail(GMAIL_ID, to, f"Subject: {sub} \n\n {msg}")
2029
s.quit()
2130

2231

2332
if __name__ == "__main__":
24-
df = pd.read_excel("data.xlsx") # the datasheet where the data of the friends is stored
33+
# the datasheet where the data of the friends is stored
34+
df = pd.read_excel("data.xlsx")
2535
today = datetime.datetime.now().strftime("%d-%m")
2636
yearNow = datetime.datetime.now().strftime("%Y")
2737

@@ -31,7 +41,8 @@ def sendEmail(to, sub, msg):
3141
bday = datetime.datetime.strptime(bday, "%d-%m-%Y")
3242
bday = bday.strftime("%d-%m")
3343
if(today == bday) and yearNow not in str(item['LastWishedYear']):
34-
sendEmail(item['Email'], "Happy Birthday", item['Dialogue']) # calling the sendmail function
44+
# calling the sendmail function
45+
sendEmail(item['Email'], "Happy Birthday", item['Dialogue'])
3546
writeInd.append(index)
3647

3748
if writeInd != None:

0 commit comments

Comments
 (0)