[Mesa-dev] [PATCH 01/41] glapi: clean imports in python files

Dylan Baker baker.dylan.c at gmail.com
Fri Apr 1 17:58:41 UTC 2016


Quoting Michael Schellenberger Costa (2016-04-01 01:30:53)
> Hi,
> 
> minor nitpicks wrt ordering below
> 
> Am 01.04.2016 um 02:04 schrieb Dylan Baker:
> > Completely clean the imports:
> > - Split so that one module is imported per line
> > - Remove unused imports
> > - Group stdlib imports, then 3rd party modules, and finally local
> >   modules
> > - sort alphabetically within those groups
> >
> > Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> > ---
> >  src/mapi/glapi/gen/glX_XML.py          | 1 -
> >  src/mapi/glapi/gen/glX_proto_common.py | 4 +++-
> >  src/mapi/glapi/gen/glX_proto_recv.py   | 4 +++-
> >  src/mapi/glapi/gen/glX_proto_send.py   | 9 +++++++--
> >  src/mapi/glapi/gen/glX_proto_size.py   | 5 +++--
> >  src/mapi/glapi/gen/glX_server_table.py | 5 ++++-
> >  src/mapi/glapi/gen/gl_SPARC_asm.py     | 3 ++-
> >  src/mapi/glapi/gen/gl_XML.py           | 8 +++++---
> >  src/mapi/glapi/gen/gl_apitemp.py       | 3 ++-
> >  src/mapi/glapi/gen/gl_enums.py         | 7 +++----
> >  src/mapi/glapi/gen/gl_genexec.py       | 6 +++---
> >  src/mapi/glapi/gen/gl_gentable.py      | 3 ++-
> >  src/mapi/glapi/gen/gl_x86-64_asm.py    | 3 ++-
> >  src/mapi/glapi/gen/gl_x86_asm.py       | 3 ++-
> >  src/mapi/glapi/gen/remap_helper.py     | 2 +-
> >  src/mapi/glapi/gen/typeexpr.py         | 4 +++-
> >  16 files changed, 45 insertions(+), 25 deletions(-)
> >
> > diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py
> > index 12ff291..6987e27 100644
> > --- a/src/mapi/glapi/gen/glX_XML.py
> > +++ b/src/mapi/glapi/gen/glX_XML.py
> > @@ -27,7 +27,6 @@
> >  
> >  import gl_XML
> >  import license
> > -import sys, getopt, string
> >  
> >  
> >  class glx_item_factory(gl_XML.gl_item_factory):
> > diff --git a/src/mapi/glapi/gen/glX_proto_common.py b/src/mapi/glapi/gen/glX_proto_common.py
> > index ae2c2d5..bcfe009 100644
> > --- a/src/mapi/glapi/gen/glX_proto_common.py
> > +++ b/src/mapi/glapi/gen/glX_proto_common.py
> > @@ -25,9 +25,11 @@
> >  # Authors:
> >  #    Ian Romanick <idr at us.ibm.com>
> >  
> > -import gl_XML, glX_XML
> >  import string
> >  
> > +import gl_XML
> > +import glX_XML

> You majoritely put glX_* first in the rest of the patch. maybe here too?

Good catch, apparently I wasn't as diligent at using the sort function
as I thought I was. I've fixed this locally.

> > +
> >  
> >  class glx_proto_item_factory(glX_XML.glx_item_factory):
> >      """Factory to create GLX protocol oriented objects derived from gl_item."""
> > diff --git a/src/mapi/glapi/gen/glX_proto_recv.py b/src/mapi/glapi/gen/glX_proto_recv.py
> > index afee388..ec3f7d7 100644
> > --- a/src/mapi/glapi/gen/glX_proto_recv.py
> > +++ b/src/mapi/glapi/gen/glX_proto_recv.py
> > @@ -28,7 +28,9 @@
> >  import argparse
> >  import string
> >  
> > -import gl_XML, glX_XML, glX_proto_common, license
> > +import glX_proto_common
> > +import gl_XML

> glX_XML is missing here, is that intentional?

Yes, it's unused in this file.

> > +import license
> >  
> >  
> >  class PrintGlxDispatch_h(gl_XML.gl_print_base):
> > diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py
> > index 2b33030..5904b33 100644
> > --- a/src/mapi/glapi/gen/glX_proto_send.py
> > +++ b/src/mapi/glapi/gen/glX_proto_send.py
> > @@ -28,9 +28,14 @@
> >  #    Jeremy Kolb <jkolb at brandeis.edu>
> >  
> >  import argparse
> > +import copy
> > +import string
> > +
> > +import gl_XML
> > +import glX_XML
> > +import glX_proto_common
> > +import license
> >  
> > -import gl_XML, glX_XML, glX_proto_common, license
> > -import copy, string
> >  
> >  def convertStringForXCB(str):
> >      tmp = ""
> > diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py
> > index 75fc26f..b008e9d 100644
> > --- a/src/mapi/glapi/gen/glX_proto_size.py
> > +++ b/src/mapi/glapi/gen/glX_proto_size.py
> > @@ -26,9 +26,10 @@
> >  #    Ian Romanick <idr at us.ibm.com>
> >  
> >  import argparse
> > -import sys, string
> > +import string
> >  
> > -import gl_XML, glX_XML
> > +import glX_XML
> > +import gl_XML
> >  import license
> >  
> >  
> > diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py
> > index 2d21f4e..5e996eb 100644
> > --- a/src/mapi/glapi/gen/glX_server_table.py
> > +++ b/src/mapi/glapi/gen/glX_server_table.py
> > @@ -27,7 +27,10 @@
> >  
> >  import argparse
> >  
> > -import gl_XML, glX_XML, glX_proto_common, license
> > +import glX_XML
> > +import glX_proto_common
> > +import gl_XML

> Ordering glX_proto_common first
> --Michael

That's just an artifact of how vim's sort function works, it puts
capitals before lower case letters (so X sorts before x), but I can
change that.

> > +import license
> >  
> >  
> >  def log2(value):
> > diff --git a/src/mapi/glapi/gen/gl_SPARC_asm.py b/src/mapi/glapi/gen/gl_SPARC_asm.py
> > index fa6217e..89bccef 100644
> > --- a/src/mapi/glapi/gen/gl_SPARC_asm.py
> > +++ b/src/mapi/glapi/gen/gl_SPARC_asm.py
> > @@ -27,8 +27,9 @@
> >  
> >  import argparse
> >  
> > +import glX_XML
> > +import gl_XML
> >  import license
> > -import gl_XML, glX_XML
> >  
> >  class PrintGenericStubs(gl_XML.gl_print_base):
> >      def __init__(self):
> > diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
> > index 2e7123e..8c622aa 100644
> > --- a/src/mapi/glapi/gen/gl_XML.py
> > +++ b/src/mapi/glapi/gen/gl_XML.py
> > @@ -26,11 +26,13 @@
> >  #    Ian Romanick <idr at us.ibm.com>
> >  
> >  from decimal import Decimal
> > -import xml.etree.ElementTree as ET
> > -import re, sys, string
> >  import os.path
> > -import typeexpr
> > +import re
> > +import string
> > +import xml.etree.ElementTree as ET
> > +
> >  import static_data
> > +import typeexpr
> >  
> >  
> >  def parse_GL_API( file_name, factory = None ):
> > diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py
> > index 5e985a2..50a599a 100644
> > --- a/src/mapi/glapi/gen/gl_apitemp.py
> > +++ b/src/mapi/glapi/gen/gl_apitemp.py
> > @@ -27,7 +27,8 @@
> >  
> >  import argparse
> >  
> > -import gl_XML, glX_XML
> > +import glX_XML
> > +import gl_XML
> >  import license
> >  
> >  class PrintGlOffsets(gl_XML.gl_print_base):
> > diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py
> > index 62cc1b3..49cc0bd 100644
> > --- a/src/mapi/glapi/gen/gl_enums.py
> > +++ b/src/mapi/glapi/gen/gl_enums.py
> > @@ -27,12 +27,11 @@
> >  #    Zack Rusin <zack at kde.org>
> >  
> >  import argparse
> > +import re
> > +import xml.etree.ElementTree as ET
> >  
> > -import license
> >  import gl_XML
> > -import xml.etree.ElementTree as ET
> > -import sys, getopt
> > -import re
> > +import license
> >  
> >  class PrintGlEnums(gl_XML.gl_print_base):
> >  
> > diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
> > index 72d7b6f..4f86bcf 100644
> > --- a/src/mapi/glapi/gen/gl_genexec.py
> > +++ b/src/mapi/glapi/gen/gl_genexec.py
> > @@ -27,10 +27,10 @@
> >  
> >  import argparse
> >  import collections
> > -import license
> > -import gl_XML
> > -import sys
> > +
> >  import apiexec
> > +import gl_XML
> > +import license
> >  
> >  
> >  exec_flavor_map = {
> > diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py
> > index 7cd475a..3ca89cd 100644
> > --- a/src/mapi/glapi/gen/gl_gentable.py
> > +++ b/src/mapi/glapi/gen/gl_gentable.py
> > @@ -32,8 +32,9 @@
> >  
> >  import argparse
> >  
> > +import glX_XML
> > +import gl_XML
> >  import license
> > -import gl_XML, glX_XML
> >  
> >  header = """/* GLXEXT is the define used in the xserver when the GLX extension is being
> >   * built.  Hijack this to determine whether this file is being built for the
> > diff --git a/src/mapi/glapi/gen/gl_x86-64_asm.py b/src/mapi/glapi/gen/gl_x86-64_asm.py
> > index dcd113e..d367feb 100644
> > --- a/src/mapi/glapi/gen/gl_x86-64_asm.py
> > +++ b/src/mapi/glapi/gen/gl_x86-64_asm.py
> > @@ -28,8 +28,9 @@
> >  import argparse
> >  import copy
> >  
> > +import glX_XML
> > +import gl_XML
> >  import license
> > -import gl_XML, glX_XML
> >  
> >  def should_use_push(registers):
> >      for [reg, offset] in registers:
> > diff --git a/src/mapi/glapi/gen/gl_x86_asm.py b/src/mapi/glapi/gen/gl_x86_asm.py
> > index c0c7941..1a0c0f4 100644
> > --- a/src/mapi/glapi/gen/gl_x86_asm.py
> > +++ b/src/mapi/glapi/gen/gl_x86_asm.py
> > @@ -27,8 +27,9 @@
> >  
> >  import argparse
> >  
> > +import glX_XML
> > +import gl_XML
> >  import license
> > -import gl_XML, glX_XML
> >  
> >  class PrintGenericStubs(gl_XML.gl_print_base):
> >  
> > diff --git a/src/mapi/glapi/gen/remap_helper.py b/src/mapi/glapi/gen/remap_helper.py
> > index edc6c3e..31a6fe4 100644
> > --- a/src/mapi/glapi/gen/remap_helper.py
> > +++ b/src/mapi/glapi/gen/remap_helper.py
> > @@ -26,8 +26,8 @@
> >  
> >  import argparse
> >  
> > -import license
> >  import gl_XML
> > +import license
> >  
> >  
> >  def get_function_spec(func):
> > diff --git a/src/mapi/glapi/gen/typeexpr.py b/src/mapi/glapi/gen/typeexpr.py
> > index ed23d23..af48fee 100644
> > --- a/src/mapi/glapi/gen/typeexpr.py
> > +++ b/src/mapi/glapi/gen/typeexpr.py
> > @@ -25,7 +25,9 @@
> >  # Authors:
> >  #    Ian Romanick <idr at us.ibm.com>
> >  
> > -import string, copy
> > +import copy
> > +import string
> > +
> >  
> >  class type_node(object):
> >      def __init__(self):
> 
> 

I've updated with changes locally.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160401/7ff1bfee/attachment-0001.sig>


More information about the mesa-dev mailing list