markdown-merge 0.1.5__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of markdown-merge might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown_merge
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Send email using markdown
5
5
  Home-page: https://github.com/AnswerDotAI/markdown_merge
6
6
  Author: Jeremy Howard
@@ -0,0 +1,2 @@
1
+ __version__ = "0.1.6"
2
+ from .core import *
@@ -38,10 +38,11 @@ def attach_file(msg, f):
38
38
  msg.attach(part)
39
39
 
40
40
  # %% ../nbs/00_core.ipynb
41
- def create_multipart_msg(subj, from_addr, to_addrs, md=None, html=None, attach=None):
41
+ def create_multipart_msg(subj, from_addr, to_addrs, md=None, html=None, attach=None, hdrs=None):
42
42
  "Create a multipart email with markdown text and HTML"
43
43
  msg = MIMEMultipart('alternative', policy=EmailPolicy())
44
44
  msg['Subject'],msg['From'] = subj,str(from_addr)
45
+ for k,v in (hdrs or {}).items(): msg[k]=v
45
46
  msg['To'] = ', '.join([str(a) for a in listify(to_addrs)])
46
47
  if md: msg.attach(MIMEText(md, 'plain'))
47
48
  if html: msg.attach(MIMEText(html, 'html'))
@@ -49,10 +50,10 @@ def create_multipart_msg(subj, from_addr, to_addrs, md=None, html=None, attach=N
49
50
  return msg
50
51
 
51
52
  # %% ../nbs/00_core.ipynb
52
- def md2email(subj, from_addr, to_addrs, md, attach=None):
53
+ def md2email(subj, from_addr, to_addrs, md, attach=None, hdrs=None):
53
54
  "Create a multipart email from markdown"
54
55
  html = markdown(md)
55
- return create_multipart_msg(subj, from_addr, to_addrs, md=md, html=html, attach=attach)
56
+ return create_multipart_msg(subj, from_addr, to_addrs, md=md, html=html, attach=attach, hdrs=hdrs)
56
57
 
57
58
  # %% ../nbs/00_core.ipynb
58
59
  def smtp_connection(host, port, user=None, password=None, use_ssl=True, use_tls=False):
@@ -65,10 +66,10 @@ def smtp_connection(host, port, user=None, password=None, use_ssl=True, use_tls=
65
66
  # %% ../nbs/00_core.ipynb
66
67
  class MarkdownMerge:
67
68
  "Send templated email merge messages formatted with Markdown"
68
- def __init__(self, addrs, from_addr, subj, msg, smtp_cfg=None, inserts=None, test=False):
69
+ def __init__(self, addrs, from_addr, subj, msg, smtp_cfg=None, inserts=None, test=False, hdrs=None):
69
70
  self.addrs,self.from_addr,self.subj,self.msg,self.i = addrs,from_addr,subj,msg,0
70
71
  self.inserts = [{}]*len(addrs) if inserts is None else inserts
71
- self.smtp_cfg,self.test = smtp_cfg,test
72
+ self.smtp_cfg,self.test,self.hdrs = smtp_cfg,test,hdrs
72
73
 
73
74
  def send_msgs(self, pause=0.2):
74
75
  "Send all unsent messages to `addrs` with `pause` secs between each send"
@@ -76,7 +77,7 @@ class MarkdownMerge:
76
77
  while self.i < len(self.addrs):
77
78
  addr,insert = self.addrs[self.i],self.inserts[self.i]
78
79
  msg = self.msg.format(**insert)
79
- eml = md2email(self.subj, self.from_addr, addr, md=msg)
80
+ eml = md2email(self.subj, self.from_addr, addr, md=msg, hdrs=self.hdrs)
80
81
  if self.test: print(f"To: {addr}\n{'-'*40}\n{msg}\n{'='*40}\n")
81
82
  else:
82
83
  conn.send_message(eml)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown_merge
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Send email using markdown
5
5
  Home-page: https://github.com/AnswerDotAI/markdown_merge
6
6
  Author: Jeremy Howard
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = markdown_merge
3
3
  lib_name = markdown_merge
4
- version = 0.1.5
4
+ version = 0.1.6
5
5
  min_python = 3.10
6
6
  license = apache2
7
7
  black_formatting = False
@@ -1,2 +0,0 @@
1
- __version__ = "0.1.5"
2
- from .core import *
File without changes
File without changes
File without changes
File without changes