Skip to content

Commit 84eac3c

Browse files
author
Tom Softreck
committed
update
1 parent 9aaa8b1 commit 84eac3c

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

email/download_attachments_in_email.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,40 @@ def download_attachments_in_email(resp, data, emailid="", outputdir="", xx=0,
1919

2020
# print("download_attachments_in_email emailid:", emailid)
2121
# resp, data = m.fetch(emailid, '(RFC822)')
22+
global type
2223
print("mail respo:", resp)
2324

25+
26+
if not isinstance(data, list):
27+
print("data is not list")
28+
return
29+
30+
if not isinstance(data[0], tuple):
31+
print("data[0] is not list")
32+
return
33+
2434
email_body = data[0][1]
35+
36+
if not isinstance(email_body, bytes):
37+
print("email_body is not bytes")
38+
return
39+
40+
# print(email_body)
41+
# print(str(email_body))
42+
# print(str(type(email_body)))
43+
# check if email_body is bytes
44+
45+
46+
#email_body = email_body.decode('utf-8')
47+
48+
# print("email_body after decode is bytes")
49+
50+
# print(type(email_body))
51+
# print(email_body)
52+
53+
# print("email_body
2554
mail = email.message_from_bytes(email_body)
55+
2656
if mail.get_content_maintype() != 'multipart':
2757
return
2858

ocr/get_company_from_pdf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# import PyPDF2
1+
#import PyPDF2
22
# python -m pip install pdfreader
33
# https://pypi.org/project/datefinder/
44
import re
5-
from pypdf import PdfReader
5+
from PyPDF2 import PdfReader
66

77
# Install:
88
# python -m pip install pdfreader
@@ -16,7 +16,6 @@
1616
def convertPdf2String(path):
1717
# load PDF file
1818
reader = PdfReader(path)
19-
number_of_pages = len(reader.pages)
2019
page = reader.pages[0]
2120
text = page.extract_text()
2221
return text

ocr/get_date_from_pdf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import dateutil.parser as dparser
1414

1515
import sys
16-
from pypdf import PdfReader
16+
from PyPDF2 import PdfReader
17+
#import PyPDF2
1718

1819

1920
# pip3 install pypdf

0 commit comments

Comments
 (0)