[PATCH 03/10] parsemail: Add series parsing
Andy Doan
andy.doan at linaro.org
Fri Jun 24 04:24:25 AEST 2016
On 06/13/2016 05:41 AM, Stephen Finucane wrote:
> +def find_series(mail):
> + """Find a patch's `SeriesRevision`.
> +
> + Args:
> + mail (email.message.Message): The mail to extract series from
> +
> + Returns:
> + The matching `SeriesRevision` instance, if any
> + """
> + series = None
> +
> + for ref in find_references(mail) + [mail.get('Message-ID').strip()]:
> + # try parsing by RFC5322 fields first
> + try:
> + series_ref = SeriesReference.objects.get(msgid=ref)
> + series = series_ref.series
> + except SeriesReference.DoesNotExist:
> + pass
> +
> + if series:
> + break
> +
> + return series
You could make this a little simpler by just doing:
for ref in find_references(mail) + [mail.get('Message-ID').strip()]:
# try parsing by RFC5322 fields first
try:
return SeriesReference.objects.get(msgid=ref).series
except SeriesReference.DoesNotExist:
pass
More information about the Patchwork
mailing list