Mercurial > p > roundup > code
comparison roundup/configuration.py @ 5305:e20f472fde7d
issue2550799: provide basic support for handling html only emails
Initial implementation and testing with the dehtml html converter
done.
The use of beautifulsoup 4 is not tested. My test system breaks when
running dehtml.py using beautiful soup. I don't get the failures when
running under the test harness, but the text output is significantly
different (different line breaks, number of newlines etc.)
The tests for dehtml need to be generated for beautiful soup and the
expected output changed. Since I have a wonky install of beautiful
soup, I don't trust my output as the standard to test against. Also
since beautiful soup is optional, the test harness needs to skip the
beautifulsoup tests if import bs4 fails. Again something outside of my
expertise. I deleted the work I had done to implement that. I could
not get it working and wanted to get this feature in in some form.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 13 Oct 2017 21:46:59 -0400 |
| parents | 32f95ec6bd8e |
| children | 5a014410f254 |
comparison
equal
deleted
inserted
replaced
| 5304:ae32f082e623 | 5305:e20f472fde7d |
|---|---|
| 322 if _val in ("strict", "lax", "none"): | 322 if _val in ("strict", "lax", "none"): |
| 323 return _val.capitalize() | 323 return _val.capitalize() |
| 324 else: | 324 else: |
| 325 raise OptionValueError(self, value, self.class_description) | 325 raise OptionValueError(self, value, self.class_description) |
| 326 | 326 |
| 327 class HtmlToTextOption(Option): | |
| 328 | |
| 329 """What module should be used to convert emails with only text/html parts into text for display in roundup. Choose from beautifulsoup 4, dehtml - the internal code or none to disable html to text conversion. If beautifulsoup chosen but not available, dehtml will be used.""" | |
| 330 | |
| 331 class_description = "Allowed values: beautifulsoup, dehtml, none" | |
| 332 | |
| 333 def str2value(self, value): | |
| 334 _val = value.lower() | |
| 335 if _val in ("beautifulsoup", "dehtml", "none"): | |
| 336 return _val | |
| 337 else: | |
| 338 raise OptionValueError(self, value, self.class_description) | |
| 339 | |
| 327 class EmailBodyOption(Option): | 340 class EmailBodyOption(Option): |
| 328 | 341 |
| 329 """When to replace message body or strip quoting: always, never or for new items only""" | 342 """When to replace message body or strip quoting: always, never or for new items only""" |
| 330 | 343 |
| 331 class_description = "Allowed values: yes, no, new" | 344 class_description = "Allowed values: yes, no, new" |
| 1010 "When parsing incoming mails, roundup uses the first\n" | 1023 "When parsing incoming mails, roundup uses the first\n" |
| 1011 "text/plain part it finds. If this part is inside a\n" | 1024 "text/plain part it finds. If this part is inside a\n" |
| 1012 "multipart/alternative, and this option is set, all other\n" | 1025 "multipart/alternative, and this option is set, all other\n" |
| 1013 "parts of the multipart/alternative are ignored. The default\n" | 1026 "parts of the multipart/alternative are ignored. The default\n" |
| 1014 "is to keep all parts and attach them to the issue."), | 1027 "is to keep all parts and attach them to the issue."), |
| 1028 (HtmlToTextOption, "convert_htmltotext", "none", | |
| 1029 "If an email has only text/html parts, use this module\n" | |
| 1030 "to convert the html to text. Choose from beautifulsoup 4,\n" | |
| 1031 "dehtml - (internal code), or none to disable conversion.\n" | |
| 1032 "If 'none' is selected, email without a text/plain part\n" | |
| 1033 "will be returned to the user with a message. If\n" | |
| 1034 "beautifulsoup is selected but not installed dehtml will\n" | |
| 1035 "be used instead."), | |
| 1015 (BooleanOption, "keep_real_from", "no", | 1036 (BooleanOption, "keep_real_from", "no", |
| 1016 "When handling emails ignore the Resent-From:-header\n" | 1037 "When handling emails ignore the Resent-From:-header\n" |
| 1017 "and use the original senders From:-header instead.\n" | 1038 "and use the original senders From:-header instead.\n" |
| 1018 "(This might be desirable in some situations where a moderator\n" | 1039 "(This might be desirable in some situations where a moderator\n" |
| 1019 "reads incoming messages first before bouncing them to Roundup)", | 1040 "reads incoming messages first before bouncing them to Roundup)", |
