Skip to content

Commit b6b4013

Browse files
committed
projects/Store_emails_in_csv/store_emails.py: PEP8 up
Also, create `def main` so the toplevel can be imported by other projects if they want to
1 parent f5b5ba2 commit b6b4013

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

projects/Store_emails_in_csv/store_emails.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/usr/bin/env python
22

3-
import imaplib
3+
import csv
44
import email
55
from email import policy
6-
import csv
7-
import ssl
6+
import imaplib
87
import os
8+
import ssl
9+
910
from bs4 import BeautifulSoup
1011

12+
1113
credential_path = os.getcwd() + "/credentials.txt"
1214
csv_path = os.getcwd() + "/mails.csv"
1315

@@ -88,8 +90,7 @@ def write_to_csv(mail, writer):
8890
writer.writerow(row)
8991

9092

91-
if __name__ == "__main__":
92-
93+
def main():
9394
mail, messages = connect_to_mailbox()
9495

9596
total_no_of_mails = int(messages[0])
@@ -104,3 +105,7 @@ def write_to_csv(mail, writer):
104105
write_to_csv(mail, writer)
105106
except Exception as e:
106107
print(e)
108+
109+
110+
if __name__ == "__main__":
111+
main()

0 commit comments

Comments
 (0)