[Mesa-dev] [PATCH 13/41] glapi: replace deprecated has_key method in python

Ian Romanick idr at freedesktop.org
Tue Apr 19 21:58:49 UTC 2016


This patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 03/31/2016 05:04 PM, Dylan Baker wrote:
> This method (and it's sibling has_* methods) are deprecated in favor of
> the 'item in container' syntax. There are countless advantages to this
> for python, but for us this is necessary to get python 3 support.
> 
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  src/mapi/glapi/gen/glX_XML.py          |  2 +-
>  src/mapi/glapi/gen/glX_proto_send.py   |  2 +-
>  src/mapi/glapi/gen/glX_proto_size.py   | 18 +++++++++---------
>  src/mapi/glapi/gen/glX_server_table.py |  6 +++---
>  src/mapi/glapi/gen/gl_XML.py           |  6 +++---
>  src/mapi/glapi/gen/gl_procs.py         |  2 +-
>  src/mapi/glapi/gen/remap_helper.py     |  2 +-
>  7 files changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py
> index a36d6ea..acc4f21 100644
> --- a/src/mapi/glapi/gen/glX_XML.py
> +++ b/src/mapi/glapi/gen/glX_XML.py
> @@ -64,7 +64,7 @@ class glx_enum(gl_XML.gl_enum):
>                  else:
>                      mode = 1
>  
> -                if not self.functions.has_key(n):
> +                if n not in self.functions:
>                      self.functions[n] = [c, mode]
>  
>  
> diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py
> index 5ca0130..731f259 100644
> --- a/src/mapi/glapi/gen/glX_proto_send.py
> +++ b/src/mapi/glapi/gen/glX_proto_send.py
> @@ -782,7 +782,7 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto):
>          print '    return%s;' % (return_name)
>  
>      def printPixelFunction(self, f):
> -        if self.pixel_stubs.has_key(f.name):
> +        if f.name in self.pixel_stubs:
>              # Normally gl_function::get_parameter_string could be
>              # used.  However, this call needs to have the missing
>              # dimensions (e.g., a fake height value for
> diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py
> index c73aaf4..d8b9c21 100644
> --- a/src/mapi/glapi/gen/glX_proto_size.py
> +++ b/src/mapi/glapi/gen/glX_proto_size.py
> @@ -71,7 +71,7 @@ class glx_enum_function(object):
>          for enum_name in enum_dict:
>              e = enum_dict[enum_name]
>  
> -            if e.functions.has_key(match_name):
> +            if match_name in e.functions:
>                  [count, mode] = e.functions[match_name]
>  
>                  if mode_set and mode != self.mode:
> @@ -79,11 +79,11 @@ class glx_enum_function(object):
>  
>                  self.mode = mode
>  
> -                if self.enums.has_key(e.value):
> +                if e.value in self.enums:
>                      if e.name not in self.enums[e.value]:
>                          self.enums[e.value].append(e)
>                  else:
> -                    if not self.count.has_key(count):
> +                    if count not in self.count:
>                          self.count[count] = []
>  
>                      self.enums[e.value] = [e]
> @@ -125,7 +125,7 @@ class glx_enum_function(object):
>          for a in self.enums:
>              count += 1
>  
> -        if self.count.has_key(-1):
> +        if -1 in self.count:
>              return 0
>  
>          # Determine if there is some mask M, such that M = (2^N) - 1,
> @@ -343,7 +343,7 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
>  
>              if (ef.is_set() and self.emit_set) or (not ef.is_set() and self.emit_get):
>                  sig = ef.signature()
> -                if enum_sigs.has_key(sig):
> +                if sig in enum_sigs:
>                      aliases.append([func.name, enum_sigs[sig]])
>                  else:
>                      enum_sigs[sig] = func.name
> @@ -464,10 +464,10 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common):
>  
>              sig = ef.signature()
>  
> -            if not enum_functions.has_key(func.name):
> +            if func.name not in enum_functions:
>                  enum_functions[func.name] = sig
>  
> -            if not enum_sigs.has_key(sig):
> +            if sig not in enum_sigs:
>                  enum_sigs[sig] = ef
>  
>          for func in api.functionIterateGlx():
> @@ -481,7 +481,7 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common):
>              if func.server_handcode or not func.has_variable_size_request():
>                  continue
>  
> -            if enum_functions.has_key(func.name):
> +            if func.name in enum_functions:
>                  sig = enum_functions[func.name]
>                  ef = enum_sigs[sig]
>  
> @@ -595,7 +595,7 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common):
>          # already be emitted, don't emit this function.  Instead, add
>          # it to the list of function aliases.
>  
> -        if self.counter_sigs.has_key(sig):
> +        if sig in self.counter_sigs:
>              n = self.counter_sigs[sig]
>              alias = [f.name, n]
>          else:
> diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py
> index 880ab87..d1a2bb9 100644
> --- a/src/mapi/glapi/gen/glX_server_table.py
> +++ b/src/mapi/glapi/gen/glX_server_table.py
> @@ -106,7 +106,7 @@ class function_table:
>                  empty = 0
>  
>                  for j in range(i, i + op_count):
> -                    if self.functions.has_key(j):
> +                    if j in self.functions:
>                          used += 1
>                      else:
>                          empty += 1
> @@ -152,7 +152,7 @@ class function_table:
>  
>      def is_empty_leaf(self, base_opcode, M):
>          for op in range(base_opcode, base_opcode + (1 << M)):
> -            if self.functions.has_key(op):
> +            if op in self.functions:
>                  return 0
>                  break
>  
> @@ -188,7 +188,7 @@ class function_table:
>                      print '    LEAF(%u),' % (len(self.lookup_table))
>  
>                      for op in range(child_base_opcode, child_base_opcode + (1 << child_M)):
> -                        if self.functions.has_key(op):
> +                        if op in self.functions:
>                              func = self.functions[op]
>                              size = func.command_fixed_length()
>  
> diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
> index 3a029cb..de10019 100644
> --- a/src/mapi/glapi/gen/gl_XML.py
> +++ b/src/mapi/glapi/gen/gl_XML.py
> @@ -884,7 +884,7 @@ class gl_api(object):
>                  temp_name = child.get("name")
>                  self.category_dict[temp_name] = [cat_name, cat_number]
>  
> -                if self.functions_by_name.has_key(func_name):
> +                if func_name in self.functions_by_name:
>                      func = self.functions_by_name[func_name]
>                      func.process_element(child)
>                  else:
> @@ -917,7 +917,7 @@ class gl_api(object):
>              if cat is None or cat == cat_name:
>                  [func_cat_type, key] = classify_category(cat_name, cat_number)
>  
> -                if not lists[func_cat_type].has_key(key):
> +                if key not in lists[func_cat_type]:
>                      lists[func_cat_type][key] = {}
>  
>                  lists[func_cat_type][key][func.name] = func
> @@ -987,7 +987,7 @@ class gl_api(object):
>          return list.__iter__()
>  
>      def get_category_for_name(self, name):
> -        if self.category_dict.has_key(name):
> +        if name in self.category_dict:
>              return self.category_dict[name]
>          else:
>              return ["<unknown category>", None]
> diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py
> index 163a8d7..362460e 100644
> --- a/src/mapi/glapi/gen/gl_procs.py
> +++ b/src/mapi/glapi/gen/gl_procs.py
> @@ -133,7 +133,7 @@ class PrintGlProcs(gl_XML.gl_print_base):
>                  for n in func.entry_points:
>                      cat, num = api.get_category_for_name(n)
>                      if cat.startswith("es") or cat.startswith("GL_OES"):
> -                        if not categories.has_key(cat):
> +                        if cat not in categories:
>                              categories[cat] = []
>                          proto = 'GLAPI %s GLAPIENTRY %s(%s);' \
>                                          % (func.return_type, "gl" + n, func.get_parameter_string(n))
> diff --git a/src/mapi/glapi/gen/remap_helper.py b/src/mapi/glapi/gen/remap_helper.py
> index e2fa0e8..5a0d6f5 100644
> --- a/src/mapi/glapi/gen/remap_helper.py
> +++ b/src/mapi/glapi/gen/remap_helper.py
> @@ -128,7 +128,7 @@ class PrintGlRemap(gl_XML.gl_print_base):
>                  # consider only GL_VERSION_X_Y or extensions
>                  c = gl_XML.real_category_name(category)
>                  if c.startswith("GL_"):
> -                    if not extension_functions.has_key(c):
> +                    if c not in extension_functions:
>                          extension_functions[c] = []
>                      extension_functions[c].append(f)
>                      # remember the ext names of the ABI
> 



More information about the mesa-dev mailing list