Mercurial > kallithea
comparison rhodecode/lib/rcmail/response.py @ 1818:cf51bbfb120e beta
auto white-space removal
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 29 Dec 2011 07:35:51 +0200 |
parents | 7ff304d3028f |
children | 349a0ca30a75 |
comparison
equal
deleted
inserted
replaced
1817:523b1011a625 | 1818:cf51bbfb120e |
---|---|
46 VALUE_IS_EMAIL_ADDRESS = lambda v: '@' in v | 46 VALUE_IS_EMAIL_ADDRESS = lambda v: '@' in v |
47 | 47 |
48 def normalize_header(header): | 48 def normalize_header(header): |
49 return string.capwords(header.lower(), '-') | 49 return string.capwords(header.lower(), '-') |
50 | 50 |
51 class EncodingError(Exception): | 51 class EncodingError(Exception): |
52 """Thrown when there is an encoding error.""" | 52 """Thrown when there is an encoding error.""" |
53 pass | 53 pass |
54 | 54 |
55 class MailBase(object): | 55 class MailBase(object): |
56 """MailBase is used as the basis of lamson.mail and contains the basics of | 56 """MailBase is used as the basis of lamson.mail and contains the basics of |
59 """ | 59 """ |
60 def __init__(self, items=()): | 60 def __init__(self, items=()): |
61 self.headers = dict(items) | 61 self.headers = dict(items) |
62 self.parts = [] | 62 self.parts = [] |
63 self.body = None | 63 self.body = None |
64 self.content_encoding = {'Content-Type': (None, {}), | 64 self.content_encoding = {'Content-Type': (None, {}), |
65 'Content-Disposition': (None, {}), | 65 'Content-Disposition': (None, {}), |
66 'Content-Transfer-Encoding': (None, {})} | 66 'Content-Transfer-Encoding': (None, {})} |
67 | 67 |
68 def __getitem__(self, key): | 68 def __getitem__(self, key): |
69 return self.headers.get(normalize_header(key), None) | 69 return self.headers.get(normalize_header(key), None) |
310 def keys(self): | 310 def keys(self): |
311 return self.base.keys() | 311 return self.base.keys() |
312 | 312 |
313 def to_message(mail): | 313 def to_message(mail): |
314 """ | 314 """ |
315 Given a MailBase message, this will construct a MIMEPart | 315 Given a MailBase message, this will construct a MIMEPart |
316 that is canonicalized for use with the Python email API. | 316 that is canonicalized for use with the Python email API. |
317 """ | 317 """ |
318 ctype, params = mail.content_encoding['Content-Type'] | 318 ctype, params = mail.content_encoding['Content-Type'] |
319 | 319 |
320 if not ctype: | 320 if not ctype: |