[Mesa-dev] [PATCH 11/41] glapi: remove superflous parens in python

Ian Romanick idr at freedesktop.org
Tue Apr 19 21:56:11 UTC 2016


On 03/31/2016 05:04 PM, Dylan Baker wrote:
> Remove parens that don't do anything. Mostly these are extra grouping
> parens in if statements, that aren't needed. Unlike C python doesn't
> require parens around the conditions of if statements, except to group
> them when using logical operators.
> 
> It also removes them around the assert keyword. assert is a keyword in
> python, it doesn't take parens, and accidentally (or purposefully to
> group) will make the assert not behave in the expected way.

I don't see assert anywhere in this patch.

> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  src/mapi/glapi/gen/gl_XML.py      | 2 +-
>  src/mapi/glapi/gen/gl_apitemp.py  | 2 +-
>  src/mapi/glapi/gen/gl_gentable.py | 2 +-
>  src/mapi/glapi/gen/gl_procs.py    | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
> index d37ebdd..74b5e5a 100644
> --- a/src/mapi/glapi/gen/gl_XML.py
> +++ b/src/mapi/glapi/gen/gl_XML.py
> @@ -758,7 +758,7 @@ class gl_function(gl_item):
>          return p_string
>  
>      def is_abi(self):
> -        return (self.offset >= 0 and not self.assign_offset)
> +        return self.offset >= 0 and not self.assign_offset
>  
>      def is_static_entry_point(self, name):
>          return name in self.static_entry_points
> diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py
> index 4b0a37e..feb5f8e 100644
> --- a/src/mapi/glapi/gen/gl_apitemp.py
> +++ b/src/mapi/glapi/gen/gl_apitemp.py
> @@ -99,7 +99,7 @@ class PrintGlOffsets(gl_XML.gl_print_base):
>              need_proto = True
>          elif self.es:
>              cat, num = api.get_category_for_name(name)
> -            if (cat.startswith("es") or cat.startswith("GL_OES")):
> +            if cat.startswith("es") or cat.startswith("GL_OES"):
>                  need_proto = True
>          if need_proto:
>              print '%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name))
> diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py
> index e8d45fb..40da816 100644
> --- a/src/mapi/glapi/gen/gl_gentable.py
> +++ b/src/mapi/glapi/gen/gl_gentable.py
> @@ -191,7 +191,7 @@ class PrintCode(gl_XML.gl_print_base):
>          funcnames = [None] * func_count
>          for f in api.functions_by_name.itervalues():
>              if f.offset != -1:
> -                if not (funcnames[f.offset] is None):
> +                if funcnames[f.offset] is not None:
>                      raise Exception("Function table has more than one function with same offset (offset %d, func %s)" % (f.offset, f.name))
>                  funcnames[f.offset] = f.name
>  
> diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py
> index 6c85bb8..163a8d7 100644
> --- a/src/mapi/glapi/gen/gl_procs.py
> +++ b/src/mapi/glapi/gen/gl_procs.py
> @@ -132,7 +132,7 @@ class PrintGlProcs(gl_XML.gl_print_base):
>              for func in api.functionIterateByOffset():
>                  for n in func.entry_points:
>                      cat, num = api.get_category_for_name(n)
> -                    if (cat.startswith("es") or cat.startswith("GL_OES")):
> +                    if cat.startswith("es") or cat.startswith("GL_OES"):
>                          if not categories.has_key(cat):
>                              categories[cat] = []
>                          proto = 'GLAPI %s GLAPIENTRY %s(%s);' \
> 



More information about the mesa-dev mailing list