예제 #1
0
파일: SMTP.py 프로젝트: JPilarr/tapyr
 def _addresses_from_header (self, addrs) :
     ### Unfortunately, the `email` package is a f*****g mess of
     ### incompatibilities between various Python versions and
     ### **badly documented** on top
     ###
     ### * Python 2 returns strings for address headers, e.g., `To`, `cc`
     ### * Python 3 returns objects for address headers, but which type of
     ###   object isn't documented, except for
     ###       `the returned value is an instance of a subclass of
     ###       email.headerregistry.BaseHeader.`
     ###   - I'd have guessed, the returned object type to be
     ###       `email.headerregistry.AddressHeader` or
     ###       `.SingleAddressHeader`
     ###     but python3.6 then died with::
     ###       'Header' object has no attribute 'addresses'
     try :
         splitter = addrs.split
     except AttributeError :
         try :
             results = addrs.addresses
         except AttributeError :
             results = [pyk.as_str (addrs)]
         else :
             results = list (pyk.as_str (r) for r in addrs.addresses)
     else :
         results = list (r.strip ()     for r in splitter (","))
     return results
예제 #2
0
파일: SMTP.py 프로젝트: xiaochang91/tapyr
 def send (self, from_addr, to_addrs, msg, mail_opts = None, rcpt_opts = None) :
     charset = self.charset
     msg_s   = pyk.decoded (msg, charset)
     self._log \
         ( pyk.as_str ("[%s] Email via %s from %s to %s\n    %s", charset)
         , datetime.datetime.now ().replace (microsecond = 0)
         , pyk.as_str (self.mail_host, charset)
         , pyk.as_str (from_addr, charset)
         , list (pyk.as_str (t, charset) for t in to_addrs)
         , pyk.as_str ("\n    ".join (msg_s.split ("\n")), charset)
         )
예제 #3
0
 def conv (s) :
     return pyk.as_str (s)
예제 #4
0
 def __call__ (self, filter) :
     return self._pq (pyk.as_str (filter))
예제 #5
0
 def __init__ (self, data) :
     self._pq = self.PyQuery (pyk.as_str (data))
예제 #6
0
 def _new (self, mt, st, b) :
     return self.MIME (pyk.as_str (b, "latin-1"), _subtype = st)
예제 #7
0
 def _new (self, mt, st, b) :
     return self.MIME \
         ( pyk.as_str (b, "latin-1")
         , _subtype = st, _charset = PMA.default_encoding
         )
예제 #8
0
파일: Response.py 프로젝트: JPilarr/tapyr
 def set_header(self, key, value, **kw):
     key = pyk.as_str(key, "ascii")
     return self.headers.set(key, value, **kw)
예제 #9
0
파일: Response.py 프로젝트: JPilarr/tapyr
 def add_header(self, key, value, **kw):
     key = pyk.as_str(key, "ascii")
     return self.headers.add(key, value, **kw)
예제 #10
0
파일: SRM.py 프로젝트: JPilarr/tapyr
 def conv (s) :
     return pyk.as_str (s)
예제 #11
0
 def _write (self, file, s) :
     file.write (pyk.as_str (s))
예제 #12
0
파일: Response.py 프로젝트: Tapyr/tapyr
 def set_header (self, key, value, ** kw) :
     key = pyk.as_str (key, "ascii")
     return self.headers.set (key, value, ** kw)
예제 #13
0
파일: Response.py 프로젝트: Tapyr/tapyr
 def add_header (self, key, value, ** kw) :
     key = pyk.as_str (key, "ascii")
     return self.headers.add (key, value, ** kw)
예제 #14
0
 def _write (self, file, s) :
     file.write (pyk.as_str (s))
예제 #15
0
 def _new(self, mt, st, b):
     return self.MIME(pyk.as_str(b, "latin-1"), _subtype=st)
예제 #16
0
 def _new(self, mt, st, b):
     return self.MIME \
         ( pyk.as_str (b, "latin-1")
         , _subtype = st, _charset = PMA.default_encoding
         )