From 80b492019daa42a4eb7e18206172ba4c3b600e91 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Thu, 26 Dec 2019 21:17:52 +0000 Subject: [PATCH] Bug 1559975 - Make layout/reftests/ lint with 'py2' and 'py3' r=catlee Depends on D36094 Differential Revision: https://phabricator.services.mozilla.com/D36095 --HG-- extra : moz-landing-system : lando --- layout/reftests/border-image/gen-refs.py | 50 ++++++++++--------- .../reftests/fonts/gsubtest/makegsubfonts.py | 15 +++--- layout/reftests/fonts/mark-generate.py | 2 + layout/reftests/fonts/math/generate.py | 2 +- layout/reftests/w3c-css/import-tests.py | 3 ++ ...enerate-text-emphasis-line-height-tests.py | 2 +- ...e-text-emphasis-position-property-tests.py | 2 +- .../generate-text-emphasis-ruby-tests.py | 2 +- ...rate-text-emphasis-style-property-tests.py | 2 +- ...egment-break-transformation-rules-tests.py | 2 +- tools/lint/py3.yml | 1 - 11 files changed, 45 insertions(+), 38 deletions(-) diff --git a/layout/reftests/border-image/gen-refs.py b/layout/reftests/border-image/gen-refs.py index 44a89353d1d5..241837ebf11d 100644 --- a/layout/reftests/border-image/gen-refs.py +++ b/layout/reftests/border-image/gen-refs.py @@ -27,6 +27,8 @@ # Assumes there is no intrinsic size for the border-image-source, so uses # the size of the border image area. +from __future__ import print_function, absolute_import + import sys class Point: @@ -65,7 +67,7 @@ class np: def parse_p(tok): if tok[-2:] == "px": return float(tok[:-2]) - print "Whoops, not a pixel value " + tok + print("Whoops, not a pixel value", tok) def parse_np(tok): if tok[-2:] == "px": @@ -121,47 +123,47 @@ def normalise(props): def check_parse(props): if not hasattr(props, 'source'): - print "missing border-image-source" + print("missing border-image-source") return False if not hasattr(props.size, 'width'): - print "missing width" + print("missing width") return False if not hasattr(props.size, 'height'): - print "missing height" + print("missing height") return False if not hasattr(props, 'width'): - print "missing border-width" + print("missing border-width") return False if not hasattr(props, 'image_width'): - print "missing border-image-width" + print("missing border-image-width") return False if not hasattr(props, 'slice'): - print "missing border-image-slice" + print("missing border-image-slice") return False if not hasattr(props, 'repeat') or (props.repeat not in ["stretch", "repeat", "round"]): - print "missing or incorrect border-image-repeat '" + props.repeat + "'" + print("missing or incorrect border-image-repeat '" + props.repeat + "'") return False if not hasattr(props, 'outset'): - print "missing border-image-outset" + print("missing border-image-outset") return False return True def check_normalise(props): if not hasattr(props, 'source'): - print "missing border-image-source" + print("missing border-image-source") return False if not hasattr(props.size, 'width'): - print "missing width" + print("missing width") return False if not hasattr(props.size, 'height'): - print "missing height" + print("missing height") return False if not hasattr(props, 'slice'): - print "missing border-image-slice" + print("missing border-image-slice") return False if not hasattr(props, 'repeat') or (props.repeat not in ["stretch", "repeat", "round"]): - print "missing or incorrect border-image-repeat '" + props.repeat + "'" + print("missing or incorrect border-image-repeat '" + props.repeat + "'") return False return True @@ -239,7 +241,7 @@ def compute(props): for t in [tiles[i] for i in [3, 4, 5]]: t.scale.y = dest_tile_size.height/t.slice.height() else: - print "Whoops, invalid border-image-repeat value" + print("Whoops, invalid border-image-repeat value") # catch overlapping slices. Its easier to deal with it here than to catch # earlier and have to avoid all the divide by zeroes above @@ -312,34 +314,34 @@ def compute(props): dest_tiles[(i+1)*tiles_h-2].dest_size.width -= diff_h # output the table to simulate the border - print "" + print("
") for i in range(tiles_h): - print "" + print("") for i in range(tiles_v): - print "" + print("") for j in range(tiles_h): width = dest_tiles[i*tiles_h+j].size.width height = dest_tiles[i*tiles_h+j].size.height # catch any tiles with negative widths/heights # this happends when the total of the border-image-slices > borde drawing area if width <= 0 or height <= 0: - print " " + print(" ") else: - print " " - print "" - print "
" + print(" ") + print("") + print("") # start here args = sys.argv[1:] if len(args) == 0: - print "whoops: no source file" + print("whoops: no source file") exit(1) props = parse(args[0]) if not check_parse(props): - print dir(props) + print(dir(props)) exit(1) props = normalise(props) if not check_normalise(props): diff --git a/layout/reftests/fonts/gsubtest/makegsubfonts.py b/layout/reftests/fonts/gsubtest/makegsubfonts.py index a8aedef0f26d..6781787afc3a 100644 --- a/layout/reftests/fonts/gsubtest/makegsubfonts.py +++ b/layout/reftests/fonts/gsubtest/makegsubfonts.py @@ -1,3 +1,4 @@ +from __future__ import print_function, absolute_import import os import textwrap @@ -124,7 +125,7 @@ def makeLookup1(): if table.format == 4: table.cmap[cp] = glyphName else: - raise NotImplementedError, "Unsupported cmap table format: %d" % table.format + raise NotImplementedError("Unsupported cmap table format: %d" % table.format) cp += 1 # tag.fail @@ -145,7 +146,7 @@ def makeLookup1(): if table.format == 4: table.cmap[cp] = glyphName else: - raise NotImplementedError, "Unsupported cmap table format: %d" % table.format + raise NotImplementedError("Unsupported cmap table format: %d" % table.format) # bump this up so that the sequence is the same as the lookup 3 font cp += 3 @@ -326,7 +327,7 @@ def makeLookup3(): if table.format == 4: table.cmap[cp] = glyphName else: - raise NotImplementedError, "Unsupported cmap table format: %d" % table.format + raise NotImplementedError("Unsupported cmap table format: %d" % table.format) cp += 1 # tag.alt1,2,3 @@ -347,7 +348,7 @@ def makeLookup3(): if table.format == 4: table.cmap[cp] = glyphName else: - raise NotImplementedError, "Unsupported cmap table format: %d" % table.format + raise NotImplementedError("Unsupported cmap table format: %d" % table.format) cp += 1 # set the glyph order @@ -474,13 +475,13 @@ def makeJavascriptData(): # build fonts -print "Making lookup type 1 font..." +print("Making lookup type 1 font...") makeLookup1() -print "Making lookup type 3 font..." +print("Making lookup type 3 font...") makeLookup3() # output javascript data -print "Making javascript data file..." +print("Making javascript data file...") makeJavascriptData() \ No newline at end of file diff --git a/layout/reftests/fonts/mark-generate.py b/layout/reftests/fonts/mark-generate.py index 8d537fa813fa..c9765c981e6e 100755 --- a/layout/reftests/fonts/mark-generate.py +++ b/layout/reftests/fonts/mark-generate.py @@ -15,6 +15,8 @@ # To install what you need, on Ubuntu, # sudo apt-get install python-fontforge +from __future__ import print_function, absolute_import + import fontforge # generate a set of fonts, each with our special glyph at one codepoint, diff --git a/layout/reftests/fonts/math/generate.py b/layout/reftests/fonts/math/generate.py index b468f2072589..f1fd4e9231d4 100644 --- a/layout/reftests/fonts/math/generate.py +++ b/layout/reftests/fonts/math/generate.py @@ -15,7 +15,7 @@ # To install what you need, on Ubuntu, # sudo apt-get install python-fontforge -from __future__ import print_function +from __future__ import print_function, absolute_import import fontforge em = 1000 diff --git a/layout/reftests/w3c-css/import-tests.py b/layout/reftests/w3c-css/import-tests.py index 7e7073b35539..4404e3759ac0 100755 --- a/layout/reftests/w3c-css/import-tests.py +++ b/layout/reftests/w3c-css/import-tests.py @@ -2,6 +2,9 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from __future__ import print_function, absolute_import + import os from optparse import OptionParser from subprocess import Popen, PIPE diff --git a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-line-height-tests.py b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-line-height-tests.py index dd823c78a68d..12fb6a3ad850 100644 --- a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-line-height-tests.py +++ b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-line-height-tests.py @@ -8,7 +8,7 @@ script outputs a list of all tests it generated in the format of Mozilla reftest.list to the stdout. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, print_function, absolute_import TEST_FILE = 'text-emphasis-line-height-{:03}{}.html' TEST_TEMPLATE = ''' diff --git a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-position-property-tests.py b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-position-property-tests.py index 62363a207bd1..527959068762 100644 --- a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-position-property-tests.py +++ b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-position-property-tests.py @@ -9,7 +9,7 @@ test files are generated by this script. It also outputs a list of all tests it generated in the format of Mozilla reftest.list to the stdout. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, print_function, absolute_import import itertools diff --git a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-ruby-tests.py b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-ruby-tests.py index b5c59e6f5018..fdbaec052e4e 100644 --- a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-ruby-tests.py +++ b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-ruby-tests.py @@ -7,7 +7,7 @@ emphasis marks with ruby in four directions. It outputs a list of all tests it generated in the format of Mozilla reftest.list to the stdout. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, print_function, absolute_import TEST_FILE = 'text-emphasis-ruby-{:03}{}.html' TEST_TEMPLATE = ''' diff --git a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-style-property-tests.py b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-style-property-tests.py index 34e047ab003e..1b1d6fc16f24 100644 --- a/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-style-property-tests.py +++ b/layout/reftests/w3c-css/submitted/text-decor-3/support/generate-text-emphasis-style-property-tests.py @@ -8,7 +8,7 @@ and , with horizontal writing mode. It outputs a list of all tests it generated in the format of Mozilla reftest.list to the stdout. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, print_function, absolute_import TEST_FILE = 'text-emphasis-style-property-{:03}{}.html' TEST_TEMPLATE = ''' diff --git a/layout/reftests/w3c-css/submitted/text3/support/generate-segment-break-transformation-rules-tests.py b/layout/reftests/w3c-css/submitted/text3/support/generate-segment-break-transformation-rules-tests.py index 75168420287b..6e13861374a6 100644 --- a/layout/reftests/w3c-css/submitted/text3/support/generate-segment-break-transformation-rules-tests.py +++ b/layout/reftests/w3c-css/submitted/text3/support/generate-segment-break-transformation-rules-tests.py @@ -18,7 +18,7 @@ So there are 49 different combinations. It outputs a list of all tests it generated in the format of Mozilla reftest.list to the stdout. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, print_function, absolute_import TEST_FILE = 'segment-break-transformation-rules-{:03}.html' TEST_TEMPLATE = ''' diff --git a/tools/lint/py3.yml b/tools/lint/py3.yml index 58f6eee4e99f..c6b64afcfb98 100644 --- a/tools/lint/py3.yml +++ b/tools/lint/py3.yml @@ -8,7 +8,6 @@ py3: - dom/canvas/test - gfx - ipc/ipdl - - layout/reftests - layout/style/ServoCSSPropList.mako.py - security/manager/ssl - testing/awsy