[Piglit] [PATCH 04/13] core.py: Simplify Environment constructor

Ilia Mirkin imirkin at alum.mit.edu
Sat Jun 21 06:39:31 PDT 2014


On Sat, Jun 21, 2014 at 8:06 AM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> This replaces assignment followed by for loops with list comprehensions.
> This is less code, simpler, and faster.
>
> Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

> ---
>  framework/core.py | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/framework/core.py b/framework/core.py
> index f61548d..6f476d0 100644
> --- a/framework/core.py
> +++ b/framework/core.py
> @@ -332,8 +332,8 @@ class Environment:
>                   verbose=False):
>          self.concurrent = concurrent
>          self.execute = execute
> -        self.filter = []
> -        self.exclude_filter = []
> +        self.filter = [re.compile(x) for x in include_filter or []]
> +        self.exclude_filter = [re.compile(x) for x in exclude_filter or []]

FYI, if you do list(re.compile(...) ... )

then it doesn't leak 'x' into the surrounding context. Doesn't really
matter, esp here, and esp with 'x'.

>          self.exclude_tests = set()
>          self.valgrind = valgrind
>          self.dmesg = dmesg
> @@ -347,17 +347,6 @@ class Environment:
>              'MESA_DEBUG': 'silent',
>          }
>
> -        """
> -        The filter lists that are read in should be a list of string objects,
> -        however, the filters need to be a list or regex object.
> -
> -        This code uses re.compile to rebuild the lists and set self.filter
> -        """
> -        for each in include_filter or []:
> -            self.filter.append(re.compile(each))
> -        for each in exclude_filter or []:
> -            self.exclude_filter.append(re.compile(each))
> -
>      def __iter__(self):
>          for key, values in self.__dict__.iteritems():
>              # If the values are regex compiled then yield their pattern
> --
> 2.0.0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list