[PATCH v2 06/11] parsemail: Restructure 'parse_content'

Andy Doan andy.doan at linaro.org
Sat Apr 9 04:06:40 AEST 2016


On 04/01/2016 09:57 AM, Stephen Finucane wrote:
> The 'parse_content' function is designed, as the title suggests, to
> parse the content of an email. It should not be used to build objects
> or similar. Move this functionality out of the function, updating the
> unit tests as necessary.
>
> Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>

Reviewed-by: Andy Doan <andy.doan at linaro.org>

> diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py

>   def find_patch_for_comment(project, refs):
> @@ -457,21 +430,18 @@ def parse_mail(mail, list_id=None):
>       """
>       # some basic sanity checks
>       if 'From' not in mail:
> -        LOGGER.debug("Ignoring patch due to missing 'From'")
> -        return 1
> +        raise ValueError("Missing 'From' header")
>
>       if 'Subject' not in mail:
> -        LOGGER.debug("Ignoring patch due to missing 'Subject'")
> -        return 1
> +        raise ValueError("Missing 'Subject' header")
>
>       if 'Message-Id' not in mail:
> -        LOGGER.debug("Ignoring patch due to missing 'Message-Id'")
> -        return 1
> +        raise ValueError("Missing 'Message-Id' header")

Thanks - cleans up a long-standing problem I've had with Linaro's use of 
the module.


More information about the Patchwork mailing list