X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=apps%2Fpatchwork%2Fbin%2Fparsemail.py;h=b0f1497656ab8ac4170c93f34975454b4f9b0fad;hb=5787cddc0bde4514cba96a360f89841e13d2e506;hp=2310ae8bc187fa52e73b9ffb7378feee0d38193f;hpb=96467db48884d72bc04fc23c8f957190fa004779;p=patchwork diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py index 2310ae8..b0f1497 100755 --- a/apps/patchwork/bin/parsemail.py +++ b/apps/patchwork/bin/parsemail.py @@ -103,7 +103,6 @@ def find_author(mail): def mail_date(mail): t = parsedate_tz(mail.get('Date', '')) if not t: - print "using now()" return datetime.datetime.utcnow() return datetime.datetime.utcfromtimestamp(mktime_tz(t)) @@ -149,9 +148,9 @@ def find_content(project, mail): if patchbuf: mail_headers(mail) - patch = Patch(name = clean_subject(mail.get('Subject')), - content = patchbuf, date = mail_date(mail), - headers = mail_headers(mail)) + name = clean_subject(mail.get('Subject'), [project.linkname]) + patch = Patch(name = name, content = patchbuf, + date = mail_date(mail), headers = mail_headers(mail)) if commentbuf: if patch: @@ -240,6 +239,8 @@ def clean_subject(subject, drop_prefixes = None): 'meep' >>> clean_subject('[PATCH] meep') 'meep' + >>> clean_subject('[PATCH] meep \\n meep') + 'meep meep' >>> clean_subject('[PATCH RFC] meep') '[RFC] meep' >>> clean_subject('[PATCH,RFC] meep') @@ -274,6 +275,9 @@ def clean_subject(subject, drop_prefixes = None): # remove Re:, Fwd:, etc subject = re_re.sub(' ', subject) + # normalise whitespace + subject = whitespace_re.sub(' ', subject) + prefixes = [] match = prefix_re.match(subject) @@ -294,8 +298,9 @@ def clean_subject(subject, drop_prefixes = None): return subject -sig_re = re.compile('^(-{2,3} ?|_+)\n.*', re.S | re.M) +sig_re = re.compile('^(-- |_+)\n.*', re.S | re.M) def clean_content(str): + """ Try to remove signature (-- ) and list footer (_____) cruft """ str = sig_re.sub('', str) return str.strip()