<commit_before>import json
import os
import sys
from jinja2 import Environment, PackageLoader

env =  Environment(loader=PackageLoader('cat'))
template = env.get_template('email.html')
# add in e-mail from https://docs.python.org/3.4/library/email-examples.html
root = os.path.dirname((os.path.realpath(__file__)))
sys.path.insert(0, root)
from cat import tools
from cat.tools import read_json

with open('subscribers.json', 'r') as fh:
  subscriptions = json.load(fh)

print(subscriptions)

cat = read_json(root + '/html/cat.json')
conferences = tools.future(cat)

print(template.render(
  events = conferences, title="Hello"
))<commit_msg>add mail service to send notification mails<commit_after>import json
import os
import sys
import smtplib
from jinja2 import Environment, PackageLoader

from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart

env =  Environment(loader=PackageLoader('cat'))
template = env.get_template('email.html')
# add in e-mail from https://docs.python.org/3.4/library/email-examples.html
root = os.path.dirname((os.path.realpath(__file__)))
sys.path.insert(0, root)
from cat import tools
from cat.tools import read_json

with open('subscribers.json', 'r') as fh:
  subscriptions = json.load(fh)

print(subscriptions)

cat = read_json(root + '/html/cat.json')
conferences = tools.future(cat)

html =template.render(
  events = conferences, title="Hello"
)

text = "Hello"
me = "me@email"
you = "me@email"


msg = MIMEMultipart('alternative')
msg['Subject'] = "Upcoming Events"
msg['From'] = me
msg['To'] = you

part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')

msg.attach(part1)
msg.attach(part2)

#s = smtplib.SMTP('localhost')
#s.sendmail(me, you, msg.as_string())
#s.quit()


with open ("file.txt", "wb") as fout:
    fout.write (bytes(msg))


{'fraction_non_alphanumeric': 0.1441937259218492, 'fraction_numerical': 0.006604292790313704, 'mean_word_length': 5.424028268551237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5657097', 'n_tokens_mistral': 636, 'n_tokens_neox': 628, 'n_words': 152}