Bug 1468273 - Fix flake8/pep8 issues by hand in gfx/ r=ted draft
authorSylvestre Ledru <sledru@mozilla.com>
Sun, 10 Jun 2018 14:15:18 +0200
changeset 817273 b0a1b5aa60e0c91cd83cec4bfffef219e70a261c
parent 817272 33413a297adc1d980c56c17799ce04f73e40ad73
child 817274 86f166b7d0dbe120056822e71b758da30ac64253
child 818787 30e22368f5882c2e0e8423103f46ff1d84da685e
push id116007
push userbmo:sledru@mozilla.com
push dateThu, 12 Jul 2018 10:21:37 +0000
reviewersted
bugs1468273
milestone63.0a1
Bug 1468273 - Fix flake8/pep8 issues by hand in gfx/ r=ted MozReview-Commit-ID: BFnq9JpWZxq
gfx/gl/GLParseRegistryXML.py
gfx/layers/d3d11/genshaders.py
gfx/thebes/gencjkcisvs.py
tools/lint/flake8.yml
--- a/gfx/gl/GLParseRegistryXML.py
+++ b/gfx/gl/GLParseRegistryXML.py
@@ -17,16 +17,17 @@
 #   Do not add the downloaded XML in the patch
 #
 # Step 4:
 #   Enjoy =)
 #
 ################################################################################
 
 # includes
+from __future__ import print_function
 import os
 import sys
 import xml.etree.ElementTree
 
 
 ################################################################################
 # export management
 
@@ -125,17 +126,17 @@ class GLDatabase:
         self.vendors = set(['EXT', 'ATI'])
         # there is no vendor="EXT" and vendor="ATI" in gl.xml,
         # so we manualy declare them
 
     def loadXML(self, path):
         xmlPath = getXMLDir() + path
 
         if not os.path.isfile(xmlPath):
-            print 'missing file "' + xmlPath + '"'
+            print('missing file "' + xmlPath + '"')
             return False
 
         tree = xml.etree.ElementTree.parse(xmlPath)
         root = tree.getroot()
 
         for enums in root.iter('enums'):
             vendor = enums.get('vendor')
             if not vendor:
--- a/gfx/layers/d3d11/genshaders.py
+++ b/gfx/layers/d3d11/genshaders.py
@@ -133,21 +133,21 @@ def find_dependencies(fxc_output):
 # Python reads the raw bytes from stdout, so we need to try our best to
 # capture that as a valid Python string.
 
 
 def decode_console_text(pipe, text):
     try:
         if pipe.encoding:
             return text.decode(pipe.encoding, 'replace')
-    except:
+    except Exception:
         pass
     try:
         return text.decode(locale.getpreferredencoding(), 'replace')
-    except:
+    except Exception:
         return text.decode('utf8', 'replace')
 
 # Allocate a temporary file name and delete it when done. We need an extra
 # wrapper for this since TemporaryNamedFile holds the file open.
 
 
 class ScopedTempFilename(object):
     def __init__(self):
@@ -158,14 +158,14 @@ class ScopedTempFilename(object):
             self.name = tmp.name
             return self.name
 
     def __exit__(self, type, value, traceback):
         if not self.name:
             return
         try:
             os.unlink(self.name)
-        except:
+        except Exception:
             pass
 
 
 if __name__ == '__main__':
     shell_main()
--- a/gfx/thebes/gencjkcisvs.py
+++ b/gfx/thebes/gencjkcisvs.py
@@ -12,25 +12,25 @@ line = f.readline()
 m = re.compile('^# (StandardizedVariants(-\d+(\.\d+)*)?\.txt)').search(line)
 fileversion = m.group(1)
 vsdict = {}
 r = re.compile('^([0-9A-F]{4,6}) (FE0[0-9A-F]); CJK COMPATIBILITY IDEOGRAPH-([0-9A-F]{4,6});')
 while True:
     line = f.readline()
     if not line:
         break
-    if not 'CJK COMPATIBILITY IDEOGRAPH-' in line:
+    if 'CJK COMPATIBILITY IDEOGRAPH-' not in line:
         continue
 
     m = r.search(line)
     unified = int(m.group(1), 16)
     vs = int(m.group(2), 16)
     compat = int(m.group(3), 16)
 
-    if not vs in vsdict:
+    if vs not in vsdict:
         vsdict[vs] = {}
     vsdict[vs][unified] = compat
 
 f.close
 
 offsets = []
 length = 10 + 11 * len(vsdict)
 for (k, mappings) in sorted(vsdict.items()):
--- a/tools/lint/flake8.yml
+++ b/tools/lint/flake8.yml
@@ -17,17 +17,16 @@ flake8:
         - python/mozboot
         - python/mozbuild/mozpack/path.py
         - python/mozlint
         - python/mozterm
         - python/mozversioncontrol
         - python/safety
         - security/
         - security/manager
-        - servo/
         - taskcluster
         - testing/firefox-ui
         - testing/mach_commands.py
         - testing/marionette/client
         - testing/marionette/harness
         - testing/marionette/puppeteer
         - testing/mochitest
         - testing/mozbase