Skip to content

Commit

Permalink
fixed a bug and add pdf_dir as an input option
Browse files Browse the repository at this point in the history
  • Loading branch information
msinamsina committed Nov 20, 2022
1 parent abfbafe commit 53a2a2b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sending_gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
import argparse
import getpass
import pandas as pd
import os


def replace_data(data, string):
for i in data.items():
print(i)
string = string.replace('${}$'.format(i[0]), i[1])
string = string.replace('${}$'.format(str(i[0])), str(i[1]))
return string


Expand All @@ -33,6 +34,7 @@ def replace_data(data, string):
parser.add_argument("--html", help="path to E-mail Html file")
parser.add_argument("--attachment", help="path to pdf file that you want to attach to your E-mail")
parser.add_argument("--cpdf", action='store_true', help="custom pdf file that you want to attach to your E-mail", default=False)
parser.add_argument("--pdf_dir", default='')

arg=parser.parse_args()

Expand Down Expand Up @@ -95,7 +97,7 @@ def replace_data(data, string):
message.attach(part)

if arg.cpdf:
filename = str(i[1]['cpdf'])
filename = os.path.join(arg.pdf_dir, str(i[1]['cpdf']) + '.pdf')

# Open PDF file in binary mode
with open(filename, "rb") as attachment:
Expand Down

0 comments on commit 53a2a2b

Please sign in to comment.