[Piglit] [PATCH 04/13] core.py: Simplify Environment constructor
Dylan Baker
baker.dylan.c at gmail.com
Sun Jun 22 15:47:18 PDT 2014
On Saturday, June 21, 2014 09:39:31 AM Ilia Mirkin wrote:
> 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'.
>
Yeah, I tend to use x y and z for that reason. I do mostly python3 (except for
piglit) and that was fixed in python3
> > 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140622/6c3c398a/attachment.sig>
More information about the Piglit
mailing list