[PATCH 02/10] parser: Add patch_get_filenames()

Finucane, Stephen stephen.finucane at intel.com
Thu Jan 7 04:12:46 AEDT 2016


On 28 Nov 10:14, Mauro Carvalho Chehab wrote:
> From: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> 
> The function returns the list of files touched by a patch, after
> stripping the leading component of the path name.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab at osg.samsung.com>
> ---
>  patchwork/parser.py | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index 13b4466a4b14..2dbbf2b7b667 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -238,6 +238,34 @@ def extract_tags(content, tags):
>  
>      return counts
>  
> +def patch_get_filenames(str):
> +    # normalise spaces
> +    str = str.replace('\r', '')
> +    str = str.strip() + '\n'
> +
> +    filenames = {}
> +
> +    for line in str.split('\n'):
> +
> +        if len(line) <= 0:
> +            continue
> +
> +        filename_match = _filename_re.match(line)
> +        if not filename_match:
> +            continue
> +
> +        filename = filename_match.group(2)
> +        if filename.startswith('/dev/null'):
> +            continue
> +
> +        filename = '/'.join(filename.split('/')[1:])
> +        filenames[filename] = True
> +
> +    filenames = filenames.keys()
> +    filenames.sort()
> +
> +    return filenames

This function needs unit tests. Other than that I'm happy with this.

Stephen


More information about the Patchwork mailing list