summaryrefslogtreecommitdiffstats
path: root/askbot/mail
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-06 23:47:25 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-06 23:47:25 -0300
commit9da9f138bad856102021a6f21389bc46bdbccb4e (patch)
tree1c07ce7ad5129dcf3dd6fb5e02020c11b7680837 /askbot/mail
parentc6105f36c41b39012a2c9edae193de24b0a9a176 (diff)
downloadaskbot-9da9f138bad856102021a6f21389bc46bdbccb4e.tar.gz
askbot-9da9f138bad856102021a6f21389bc46bdbccb4e.tar.bz2
askbot-9da9f138bad856102021a6f21389bc46bdbccb4e.zip
added a logging message for separators that do not match any regexes
Diffstat (limited to 'askbot/mail')
-rw-r--r--askbot/mail/parsing.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/askbot/mail/parsing.py b/askbot/mail/parsing.py
index 919c3f02..64a8f4a3 100644
--- a/askbot/mail/parsing.py
+++ b/askbot/mail/parsing.py
@@ -2,6 +2,7 @@
this file is a candidate for publishing as an independent module
"""
import re
+import sys
#Regexes for quote separators
#add more via variables ending with _QUOTE_RE
@@ -43,20 +44,19 @@ def strip_trailing_empties_and_quotes(text):
def strip_leading_empties(text):
return re.sub(r'\A[\n\s\xa0]*', '', text)
-def strip_email_client_formatting(text):
- """strips email client formatting from the responses,
- such as empty lines and quote separators (on ... wrote)
+def strip_email_client_quote_separator(text):
+ """strips email client quote separator from the responses,
+ e.g. (on such date XYZ wrote)
if one client-specific separator matches, then result
is immediately returned
"""
- text = strip_trailing_empties_and_quotes(text)
for regex in CLIENT_SPECIFIC_QUOTE_REGEXES:
if regex.search(text):
- text = regex.sub('', text)
- break
- text = strip_trailing_empties_and_quotes(text)
- return strip_leading_empties(text)
+ return regex.sub('', text)
+ #did not find a quote separator!!! log it
+ sys.stderr.write('no quote separator: %s\n' % text)
+ return text
def extract_reply_contents(text, reply_separator=None):
"""If reply_separator is given,
@@ -75,4 +75,8 @@ def extract_reply_contents(text, reply_separator=None):
text = reply_separator.split(text)[0]
else:
raise ValueError('reply_separator must be a string or a compiled regex')
- return strip_email_client_formatting(text)
+
+ text = strip_trailing_empties_and_quotes(text)
+ text = strip_email_client_quote_separator(text)
+ text = strip_trailing_empties_and_quotes(text)
+ return strip_leading_empties(text)