Changeset 271151 in webkit


Ignore:
Timestamp:
Jan 5, 2021, 9:59:56 AM (4 years ago)
Author:
ap@apple.com
Message:

Update root level scripts in Tools/Scripts to Python 3
https://bugs.webkit.org/show_bug.cgi?id=220200

Reviewed by Darin Adler and Jonathan Bedard.

Mostly 2to3 inspired.

  • Scripts/check-for-global-bss-symbols-in-webkitgtk-libs:
  • Scripts/check-for-invalid-symbols-in-version-script:
  • Scripts/check-for-platform-layering-violations:
  • Scripts/clean-webkit:
  • Scripts/compare-results:
  • Scripts/compare-webkit-configurations:
  • Scripts/download-github-release.py:
  • Scripts/dump-webkit-tests-run:
  • Scripts/export-w3c-performance-wg-tests:
  • Scripts/extract-dependencies-from-makefile:
  • Scripts/extract-localizable-strings:
  • Scripts/find-duplicate-files:
  • Scripts/ic-stats.py:
  • Scripts/import-w3c-performance-wg-tests:
  • Scripts/make-dist:
  • Scripts/malloc-tree:
  • Scripts/mark-jsc-stress-test:
  • Scripts/open-layout-test:
  • Scripts/read-checksum-from-png:
  • Scripts/rebase-patch-after-webkit-move:
  • Scripts/run-gtk-tests:
  • Scripts/run-webdriver-tests:
  • Scripts/run-wpe-tests:
  • Scripts/sampstat:
  • Scripts/sync-feature-defines:
  • Scripts/sync-master-with-upstream:
  • Scripts/update-wasm-gcc-torture.py:
  • Scripts/validate-committer-lists:
Location:
trunk/Tools
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Tools/ChangeLog

    r271147 r271151  
     12021-01-05  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Update root level scripts in Tools/Scripts to Python 3
     4        https://bugs.webkit.org/show_bug.cgi?id=220200
     5
     6        Reviewed by Darin Adler and Jonathan Bedard.
     7
     8        Mostly 2to3 inspired.
     9
     10        * Scripts/check-for-global-bss-symbols-in-webkitgtk-libs:
     11        * Scripts/check-for-invalid-symbols-in-version-script:
     12        * Scripts/check-for-platform-layering-violations:
     13        * Scripts/clean-webkit:
     14        * Scripts/compare-results:
     15        * Scripts/compare-webkit-configurations:
     16        * Scripts/download-github-release.py:
     17        * Scripts/dump-webkit-tests-run:
     18        * Scripts/export-w3c-performance-wg-tests:
     19        * Scripts/extract-dependencies-from-makefile:
     20        * Scripts/extract-localizable-strings:
     21        * Scripts/find-duplicate-files:
     22        * Scripts/ic-stats.py:
     23        * Scripts/import-w3c-performance-wg-tests:
     24        * Scripts/make-dist:
     25        * Scripts/malloc-tree:
     26        * Scripts/mark-jsc-stress-test:
     27        * Scripts/open-layout-test:
     28        * Scripts/read-checksum-from-png:
     29        * Scripts/rebase-patch-after-webkit-move:
     30        * Scripts/run-gtk-tests:
     31        * Scripts/run-webdriver-tests:
     32        * Scripts/run-wpe-tests:
     33        * Scripts/sampstat:
     34        * Scripts/sync-feature-defines:
     35        * Scripts/sync-master-with-upstream:
     36        * Scripts/update-wasm-gcc-torture.py:
     37        * Scripts/validate-committer-lists:
     38
    1392021-01-05  Youenn Fablet  <youenn@apple.com>
    240
  • TabularUnified trunk/Tools/Scripts/check-for-global-bss-symbols-in-webkitgtk-libs

    r270583 r271151  
    2020
    2121if len(sys.argv) < 3:
    22     print "Usage: %s lib1 lib2" % sys.argv[0]
     22    print("Usage: %s lib1 lib2" % sys.argv[0])
    2323    sys.exit(1)
    2424
     
    3232
    3333if symbols:
    34     print 'The following symbols are global in %s and not in %s' % (sys.argv[1], sys.argv[2])
    35     print '\n'.join(sorted(symbols))
     34    print('The following symbols are global in %s and not in %s' % (sys.argv[1], sys.argv[2]))
     35    print('\n'.join(sorted(symbols)))
    3636    sys.exit(1)
    3737
  • TabularUnified trunk/Tools/Scripts/check-for-invalid-symbols-in-version-script

    r227057 r271151  
    2121
    2222if len(sys.argv) < 3:
    23     print "Usage: %s script lib" % sys.argv[0]
     23    print("Usage: %s script lib" % sys.argv[0])
    2424    sys.exit(1)
    2525
     
    3535
    3636if symbols:
    37     print 'The following symbols are in version script %s and not in library %s' % (sys.argv[1], sys.argv[2])
    38     print '\n'.join(sorted(symbols))
     37    print('The following symbols are in version script %s and not in library %s' % (sys.argv[1], sys.argv[2]))
     38    print('\n'.join(sorted(symbols)))
    3939    sys.exit(1)
    4040
  • TabularUnified trunk/Tools/Scripts/check-for-platform-layering-violations

    r178167 r271151  
    5454
    5555        if header not in platform_headers and header not in PLATFORM_GENERATED_HEADERS:
    56             print "ERROR: %s:%d %s" % (source_file[len(checkout_root) + 1:], line_count, line.strip('\n'))
     56            print("ERROR: %s:%d %s" % (source_file[len(checkout_root) + 1:], line_count, line.strip('\n')))
    5757            failures_found += 1
    5858
     
    7474
    7575if layering_violations_count:
    76     print "Total: %d layering violations found in %s" % (layering_violations_count, platform_dir[len(checkout_root) + 1:])
     76    print("Total: %d layering violations found in %s" % (layering_violations_count, platform_dir[len(checkout_root) + 1:]))
    7777    sys.exit(1)
    7878
  • TabularUnified trunk/Tools/Scripts/clean-webkit

    r266456 r271151  
    6767            files = listWebKitBuildFiles(fs)
    6868            keepDirs = usesFlatpak() and ["Toolchains", "UserFlatpak"] or ["DependenciesGTK", "DependenciesWPE"]
    69             files = filter(lambda path: path[len("WebKitBuild/"):] not in keepDirs, files)
     69            files = [path for path in files if path[len("WebKitBuild/"):] not in keepDirs]
    7070            removeFiles(fs, files)
    7171    else:
  • TabularUnified trunk/Tools/Scripts/compare-results

    r263629 r271151  
    3737    from scipy import stats
    3838except:
    39     print "ERROR: scipy package is not installed. Run `pip install scipy`"
     39    print("ERROR: scipy package is not installed. Run `pip install scipy`")
    4040    sys.exit(1)
    4141
     
    4343    import numpy
    4444except:
    45     print "ERROR: numpy package is not installed. Run `pip install numpy`"
     45    print("ERROR: numpy package is not installed. Run `pip install numpy`")
    4646    sys.exit(1)
    4747
     
    229229    strings.append(verticalSeparator)
    230230
    231     print "\n"
     231    print("\n")
    232232    for s in strings:
    233233        print(s)
    234     print "\n"
     234    print("\n")
    235235
    236236def writeCSV(a, b, fileName):
     
    328328    else:
    329329        payload = payload["MotionMark-1.1.1"]
    330     testNames = payload["tests"].keys()
     330    testNames = list(payload["tests"].keys())
    331331    numTests = len(payload["tests"][testNames[0]]["metrics"]["Score"]["current"])
    332332    results = []
     
    366366        return False
    367367
    368     print "Should not be reached."
     368    print("Should not be reached.")
    369369    assert False
    370370
     
    374374    aMean = numpy.mean(a)
    375375    bMean = numpy.mean(b)
    376     print "a mean = {:.5f}".format(aMean)
    377     print "b mean = {:.5f}".format(bMean)
    378 
    379     print "pValue = {:.10f}".format(pValue)
     376    print("a mean = {:.5f}".format(aMean))
     377    print("b mean = {:.5f}".format(bMean))
     378
     379    print("pValue = {:.10f}".format(pValue))
    380380
    381381    if biggerIsBetter(benchmarkType):
    382         print "(Bigger means are better.)"
     382        print("(Bigger means are better.)")
    383383        if aMean > bMean:
    384             print "{:.3f} times worse".format((aMean / bMean))
     384            print("{:.3f} times worse".format((aMean / bMean)))
    385385        else:
    386             print "{:.3f} times better".format((bMean / aMean))
     386            print("{:.3f} times better".format((bMean / aMean)))
    387387    else:
    388         print "(Smaller means are better.)"
     388        print("(Smaller means are better.)")
    389389        if aMean > bMean:
    390             print "{:.3f} times better".format((aMean / bMean))
     390            print("{:.3f} times better".format((aMean / bMean)))
    391391        else:
    392             print "{:.3f} times worse".format((bMean / aMean))
     392            print("{:.3f} times worse".format((bMean / aMean)))
    393393
    394394    if pValue <= 0.05:
    395         print "Results ARE significant"
     395        print("Results ARE significant")
    396396    else:
    397         print "Results ARE NOT significant"
     397        print("Results ARE NOT significant")
    398398
    399399def getOptions():
     
    439439
    440440    if typeA != typeB:
    441         print "-a and -b are not the same benchmark. a={} b={}".format(typeA, typeB)
     441        print("-a and -b are not the same benchmark. a={} b={}".format(typeA, typeB))
    442442        sys.exit(1)
    443443
    444444    if not (typeA and typeB):
    445         print "Unknown benchmark type. a={} b={}".format(typeA, typeB)
     445        print("Unknown benchmark type. a={} b={}".format(typeA, typeB))
    446446        sys.exit(1)
    447447   
     
    480480            writeCSV(plt5Breakdown(a), plt5Breakdown(b), args.csv)
    481481    else:
    482         print "Unknown benchmark type"
     482        print("Unknown benchmark type")
    483483        sys.exit(1)
    484484
  • TabularUnified trunk/Tools/Scripts/compare-webkit-configurations

    r258075 r271151  
    4040    force_webkit2 = args.webkit2
    4141    if args.comparison == "remote-layer-tree":
    42         print "Forcing use of WebKit2, as the remote layer tree depends on WebKit2."
     42        print("Forcing use of WebKit2, as the remote layer tree depends on WebKit2.")
    4343        force_webkit2 = True
    4444
    4545    if args.comparison == "webkit2" and force_webkit2:
    46         print "It doesn't make sense to test WebKit1 vs. WebKit2 *and* force WebKit2 on."
     46        print("It doesn't make sense to test WebKit1 vs. WebKit2 *and* force WebKit2 on.")
    4747        sys.exit(1)
    4848
     
    6666        return "-2"
    6767
    68     print "Unknown comparison:", comparison_name
     68    print("Unknown comparison:", comparison_name)
    6969    sys.exit(1)
    7070
  • TabularUnified trunk/Tools/Scripts/download-github-release.py

    r255243 r271151  
    119119    version_info_path = binary_path + '.version'
    120120
    121     print(('Updating {}...'.format(args.filename)))
     121    print('Updating {}...'.format(args.filename))
    122122
    123123    existing_version_info = load_version_info(version_info_path)
    124124    if existing_version_info:
    125         print(('Found existing release: {}'.format(existing_version_info['tag_name'])))
     125        print('Found existing release: {}'.format(existing_version_info['tag_name']))
    126126    else:
    127127        print('No existing release found.')
    128128
    129129    release_title = 'release "{}"'.format(args.release_tag) if args.release_tag else 'latest release'
    130     print(('Seeking {} from {}...'.format(release_title, args.repo)))
     130    print('Seeking {} from {}...'.format(release_title, args.repo))
    131131    release_url, target_version_info = find_release(args.endpoint, args.repo, args.filename, args.token, args.release_tag)
    132132
     
    148148        os.makedirs(args.output_dir)
    149149
    150     print(('Downloading to {}...'.format(os.path.abspath(args.output_dir))))
     150    print('Downloading to {}...'.format(os.path.abspath(args.output_dir)))
    151151    download_release(release_url, binary_path, args.token)
    152152    save_version_info(version_info_path, target_version_info)
  • TabularUnified trunk/Tools/Scripts/dump-webkit-tests-run

    r226395 r271151  
    11#!/usr/bin/env python
     2
     3# A webkitpy import needs to go first for autoinstaller to work with subsequent imports.
     4import webkitpy
     5
    26import json
    37import optparse
    48import os
     9import six
    510import sys
    611
     
    1621                trie = json.load(fp)
    1722        else:
    18             print >> sys.stderr, "file not found: %s" % args[0]
     23            six.print_("file not found: %s" % args[0], file=sys.stderr)
    1924            sys.exit(1)
    2025    else:
     
    2328    results = convert_trie_to_flat_paths(trie)
    2429    tests_run = []
    25     for (test, result) in results.iteritems():
     30    for (test, result) in six.iteritems(results):
    2631        # Each result is a dict containing
    2732        # { 'results': [worker #, test # in worker, driver pid,
     
    3035            tests_run.append((test, result['results'][1]))
    3136
    32     print "\n".join(t[0] for t in sorted(tests_run, key=lambda t: t[1]))
     37    print("\n".join(t[0] for t in sorted(tests_run, key=lambda t: t[1])))
    3338
    3439
     
    3742    # so that this code can stand alone.
    3843    result = {}
    39     for name, data in trie.iteritems():
     44    for name, data in six.iteritems(trie):
    4045        if prefix:
    4146            name = prefix + "/" + name
  • TabularUnified trunk/Tools/Scripts/export-w3c-performance-wg-tests

    r143989 r271151  
    4444
    4545if len(sys.argv) != 3:
    46     print 'USAGE: %s path_to_webkit_checkout_root path_to_webperf_checkout_root' % sys.argv[0]
     46    print('USAGE: %s path_to_webkit_checkout_root path_to_webperf_checkout_root' % sys.argv[0])
    4747    sys.exit(1)
    4848
     
    7878                            line = line.replace(to_find, replace_with)
    7979                        out_file.write(line)
    80                 print 'Exported %s' % os.path.join(root, filename)
     80                print('Exported %s' % os.path.join(root, filename))
  • TabularUnified trunk/Tools/Scripts/extract-dependencies-from-makefile

    r240503 r271151  
    3434# to the specified files.
    3535
    36 
    37 from __future__ import print_function
    3836
    3937import argparse
  • TabularUnified trunk/Tools/Scripts/extract-localizable-strings

    r235190 r271151  
    11#!/bin/sh
    22
    3 exec "$(dirname $0)/../../Source/WebCore/Scripts/extract-localizable-strings.pl" "$@"
     3exec("$(dirname $0)/../../Source/WebCore/Scripts/extract-localizable-strings.pl" "$@")
  • TabularUnified trunk/Tools/Scripts/find-duplicate-files

    r265187 r271151  
    5454
    5555for fileList in sorted(duplicates):
    56     print fileList
     56    print(fileList)
  • TabularUnified trunk/Tools/Scripts/ic-stats.py

    r244204 r271151  
    7575
    7676    def dumpStats(self):
    77         print "Total Slow getById = {0:>13,d}".format(self.totalSlowGetById)
    78         print "Total Slow putById = {0:>13,d}".format(self.totalSlowPutById)
     77        print("Total Slow getById = {0:>13,d}".format(self.totalSlowGetById))
     78        print("Total Slow putById = {0:>13,d}".format(self.totalSlowPutById))
    7979
    80         print "Operation                            Base                  Property                              Location          Count  % tot"
    81         print "-----------------------------------  --------------------  ------------------------------------  ------------  ---------   slow"
     80        print("Operation                            Base                  Property                              Location          Count  % tot")
     81        print("-----------------------------------  --------------------  ------------------------------------  ------------  ---------   slow")
    8282
    8383        keys = sorted(self.combinedRecords.keys(), key=lambda t: self.combinedRecords[t], reverse=True)
     
    9898                property = property[0:32] + "..."
    9999
    100             print "{0:35}  {1:20}  {2:36}  {3:12}  {4:>9d}{5}".format(operation[0:34], base, property, key[3], count, slowPercent)
     100            print("{0:35}  {1:20}  {2:36}  {3:12}  {4:>9d}{5}".format(operation[0:34], base, property, key[3], count, slowPercent))
    101101
    102102
    103103def usage():
    104     print "Usage: {0} [ic-stats-file]".format(sys.argv[0])
    105     print "        Where <ic-stats-file> is the results of using the useICStats option."
     104    print("Usage: {0} [ic-stats-file]".format(sys.argv[0]))
     105    print("        Where <ic-stats-file> is the results of using the useICStats option.")
    106106    exit(1)
    107107
     
    113113            file = open(sys.argv[1], "r")
    114114        except IOError as e:
    115             print "Couldn't open {0}, {1}".format(sys.argv[1], e.strerror)
     115            print("Couldn't open {0}, {1}".format(sys.argv[1], e.strerror))
    116116            usage()
    117117        except:
    118             print "Unexpected error:", sys.exc_info()[0]
     118            print("Unexpected error:", sys.exc_info()[0])
    119119            usage()
    120120    else:
  • TabularUnified trunk/Tools/Scripts/import-w3c-performance-wg-tests

    r143989 r271151  
    4343
    4444if len(sys.argv) != 3:
    45     print 'USAGE: %s path_to_webperf_checkout_root path_to_webkit_checkout_root' % sys.argv[0]
     45    print('USAGE: %s path_to_webperf_checkout_root path_to_webkit_checkout_root' % sys.argv[0])
    4646    sys.exit(1)
    4747
     
    5050
    5151if os.path.exists(destination_directory):
    52     print 'Refusing to overwrite existing directory: %s' % destination_directory
     52    print('Refusing to overwrite existing directory: %s' % destination_directory)
    5353    sys.exit(1)
    5454os.makedirs(destination_directory)
  • TabularUnified trunk/Tools/Scripts/make-dist

    r270583 r271151  
    1616# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    1717
    18 from __future__ import print_function
    1918from contextlib import closing
    2019
     
    121120                return Ruleset.global_rules().passes(entry) and self.rules.passes(entry)
    122121
    123             to_keep = filter(passes_all_rules, dirs)
     122            to_keep = list(filter(passes_all_rules, dirs))
    124123            del dirs[:]
    125124            dirs.extend(to_keep)
     
    238237            try:
    239238                os.mkdir(directory)
    240             except OSError, e:
     239            except OSError as e:
    241240                if e.errno != errno.EEXIST or not os.path.isdir(directory):
    242241                    raise Exception("Could not create %s dir at %s: %s" % (directory_type, directory, str(e)))
  • TabularUnified trunk/Tools/Scripts/malloc-tree

    r165676 r271151  
    199199    sortedRootNodes = sorted(rootNodes.values(), key=sortKeyByBytes, reverse=True)
    200200
    201     print 'Call graph:'
     201    print('Call graph:')
    202202    try:
    203203        for node in sortedRootNodes:
    204204            node.printNode()
    205             print
     205            print()
    206206    except:
    207207        pass
  • TabularUnified trunk/Tools/Scripts/mark-jsc-stress-test

    r251161 r271151  
    7575        skip_conditions = []
    7676        skip_line = "{} {} {}"
    77         supported_variables = filter(lambda variable: variable in self._conditions, JSCTestModifier.variables)
     77        supported_variables = [variable for variable in JSCTestModifier.variables if variable in self._conditions]
    7878        condition_template = "{}" if len(supported_variables) == 1 else "({})"
    7979        for variable in supported_variables:
  • TabularUnified trunk/Tools/Scripts/open-layout-test

    r217276 r271151  
    6666    test_url = driver.test_to_uri(test_name)
    6767    if not needs_server:
    68         print "Opening %s" % test_url
     68        print("Opening %s" % test_url)
    6969        subprocess.Popen(['open', test_url])
    7070        return
  • TabularUnified trunk/Tools/Scripts/read-checksum-from-png

    r118884 r271151  
    2828# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929
    30 from __future__ import with_statement
    3130import sys
    3231
     
    3736    for filename in sys.argv[1:]:
    3837        with open(filename, 'r') as filehandle:
    39             print "%s: %s" % (read_checksum_from_png.read_checksum(filehandle), filename)
     38            print("%s: %s" % (read_checksum_from_png.read_checksum(filehandle), filename))
  • TabularUnified trunk/Tools/Scripts/rebase-patch-after-webkit-move

    r219477 r271151  
    2222# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2323
     24# A webkitpy import needs to go first for autoinstaller to work with subsequent imports.
     25import webkitpy
     26
    2427import os
     28import six
    2529import sys
    2630
     
    4953        return RebaseStatus.DO_NOT_NEED
    5054
    51     for current_name, rebased_name in REBASE_DICTIONARY.iteritems():
     55    for current_name, rebased_name in six.iteritems(REBASE_DICTIONARY):
    5256        # Check if we've already rebased. We need to check if the rebased_name is already in the REBASE_DICTIONARY,
    5357        # in this case, we don't know if we've already been rebased.
     
    6165
    6266    # Check if we might need a rebase
    63     for current_name, rebased_name in REBASE_DICTIONARY.iteritems():
     67    for current_name, rebased_name in six.iteritems(REBASE_DICTIONARY):
    6468        if append_source(current_name) in line:
    6569            return RebaseStatus.MAYBE_NEED
     
    7074def rebase_line(line):
    7175    if not is_editable_line(line):
    72         for current_name, rebased_name in REBASE_DICTIONARY.iteritems():
     76        for current_name, rebased_name in six.iteritems(REBASE_DICTIONARY):
    7377            if current_name in line:
    7478                sys.stderr.write('Found an instance of {} in the patch.  Did you mean to replace it with {}?\n'.format(current_name, rebased_name))
    7579        return line
    76     for current_name, rebased_name in REBASE_DICTIONARY.iteritems():
     80    for current_name, rebased_name in six.iteritems(REBASE_DICTIONARY):
    7781        if append_source(current_name) in line:
    7882            return line.replace(append_source(current_name), append_source(rebased_name))
     
    119123        return []
    120124    elif sys.argv[1] == '-h' or sys.argv[1] == 'help':
    121         print 'rebase-patch-after-webkit-move usage:'
    122         print '\trebase-patch-after-webkit-move -h, help'
    123         print '\t\tPrint this message'
    124         print '\trebase-patch-after-webkit-move <path to patch>'
    125         print '\t\tReplace the patch at the provided path with a rebased patch'
    126         print '\trebase-patch-after-webkit-move'
    127         print '\t\tTreat stdin as the patch to be rebased'
     125        print('rebase-patch-after-webkit-move usage:')
     126        print('\trebase-patch-after-webkit-move -h, help')
     127        print('\t\tPrint this message')
     128        print('\trebase-patch-after-webkit-move <path to patch>')
     129        print('\t\tReplace the patch at the provided path with a rebased patch')
     130        print('\trebase-patch-after-webkit-move')
     131        print('\t\tTreat stdin as the patch to be rebased')
    128132        exit(0)
    129133
  • TabularUnified trunk/Tools/Scripts/run-gtk-tests

    r263743 r271151  
    1818# Boston, MA 02110-1301, USA.
    1919
    20 from __future__ import print_function
    2120import logging
    2221import subprocess
  • TabularUnified trunk/Tools/Scripts/run-webdriver-tests

    r263261 r271151  
    6161try:
    6262    port = Host().port_factory.get(options.platform, options)
    63 except NotImplementedError, e:
     63except NotImplementedError as e:
    6464    _log.error(str(e))
    6565    sys.exit(-1)
     
    7777
    7878        if not jhbuildutils.enter_jhbuild_environment_if_available(port.name()):
    79             print '***'
    80             print '*** Warning: jhbuild environment not present and not running in flatpak.'
    81             print '*** Run update-webkitgtk-libs or update-webkit-flatpak before build-webkit to ensure proper testing..'
    82             print '***'
     79            print('***')
     80            print('*** Warning: jhbuild environment not present and not running in flatpak.')
     81            print('*** Run update-webkitgtk-libs or update-webkit-flatpak before build-webkit to ensure proper testing..')
     82            print('***')
    8383
    8484runner = WebDriverTestRunner(port)
  • TabularUnified trunk/Tools/Scripts/run-wpe-tests

    r263950 r271151  
    1818# Boston, MA 02110-1301, USA.
    1919
    20 from __future__ import print_function
    2120import logging
    2221import os
  • TabularUnified trunk/Tools/Scripts/sampstat

    r165676 r271151  
    2929import fileinput
    3030from optparse import OptionParser
     31from functools import reduce
    3132
    3233usage = "usage: %prog [options] [FILES]\n  Compute the mean and 95% confidence interval of a sample set.\n  Standard input or files must contain two or more decimal numbers, one per line."
     
    8990    for item in results:
    9091        line = "      %.2f %s" % (item, options.unit)
    91         print line
     92        print(line)
    9293        length = len(line) if len(line) > length else length
    9394
    94     print "-" * length
     95    print("-" * length)
    9596
    9697prefix = "Mean: " if options.verbose else ""
    97 print "%s%.2f %s +/- %.2f %s (%.1f%%)" % (prefix, mean, options.unit, confidenceInterval, options.unit, confidencePercent)
     98print("%s%.2f %s +/- %.2f %s (%.1f%%)" % (prefix, mean, options.unit, confidenceInterval, options.unit, confidencePercent))
    9899
  • TabularUnified trunk/Tools/Scripts/sync-feature-defines

    r213395 r271151  
    2626"Copies the most recently updated FeatureDefines.xcconfig file to all the others."
    2727
     28# A webkitpy import needs to go first for autoinstaller to work with subsequent imports.
     29from webkitpy.style.checkers.featuredefines import FEATURE_DEFINE_FILES
     30
    2831import os
    2932import shutil
    30 from webkitpy.style.checkers.featuredefines import FEATURE_DEFINE_FILES
     33import six
     34
    3135
    3236newest_file = max(FEATURE_DEFINE_FILES, key=os.path.getctime)
     
    3438remaining_files.remove(newest_file)
    3539
    36 print "Copy %s to each of: %s " % (newest_file, ", ".join(remaining_files))
    37 response = raw_input("Continue [Y/n]: ")
     40print("Copy %s to each of: %s " % (newest_file, ", ".join(remaining_files)))
     41response = six.moves.input("Continue [Y/n]: ")
    3842
    3943if not response:
  • TabularUnified trunk/Tools/Scripts/sync-master-with-upstream

    r111823 r271151  
    3939    if subprocess.call(args) != 0:
    4040        if error_message:
    41             print error_message
     41            print(error_message)
    4242        exit(1)
    4343
    4444run(["git", "fetch", "upstream"], "Have you run configure-github-as-upstream to configure an upstream repository?")
    4545run(["git", "push", "origin", "upstream/master:master"])
    46 print "\nConsider running 'git merge origin' to update your local branches."
     46print("\nConsider running 'git merge origin' to update your local branches.")
  • TabularUnified trunk/Tools/Scripts/update-wasm-gcc-torture.py

    r225698 r271151  
    3232import sys
    3333import tarfile
    34 import urllib2
     34
     35if sys.version_info > (3, 0):
     36    from urllib.request import urlopen
     37else:
     38    from urllib2 import urlopen
    3539
    3640LKGR_URL = 'https://storage.googleapis.com/wasm-llvm/builds/%s/lkgr.json'
     
    6670    if not args.lkgr:
    6771        print('Downloading: %s' % lkgr_url)
    68         args.lkgr = json.loads(urllib2.urlopen(lkgr_url).read())['build']
     72        args.lkgr = json.loads(urlopen(lkgr_url).read())['build']
    6973    print('lkgr: %s' % args.lkgr)
    7074
     
    7579    if not os.path.exists(torture_file):
    7680        print('Downloading: %s' % torture_url)
    77         torture_download = urllib2.urlopen(torture_url)
     81        torture_download = urlopen(torture_url)
    7882        with open(torture_file, 'wb') as f:
    7983            f.write(torture_download.read())
  • TabularUnified trunk/Tools/Scripts/validate-committer-lists

    r246414 r271151  
    3434import logging
    3535import os
     36import re
    3637import subprocess
    37 import re
    38 import urllib2
     38import sys
     39
    3940from datetime import date, datetime, timedelta
    4041from optparse import OptionParser
     42
     43if sys.version_info > (3, 0):
     44    from urllib.request import urlopen
     45else:
     46    from urllib2 import urlopen
    4147
    4248from webkitpy.common.config.committers import CommitterList
     
    5460    if not list_to_print:
    5561        return
    56     print # Newline before the list
    57     print title
     62    print() # Newline before the list
     63    print(title)
    5864    for item in list_to_print:
    59         print item
     65        print(item)
    6066
    6167
     
    6571
    6672    def _fetch_emails_from_page(self, url):
    67         page = urllib2.urlopen(url)
     73        page = urlopen(url)
    6874        soup = BeautifulSoup(page)
    6975
     
    94100                email_to_committer_map[email] = committer
    95101
    96         return filter(lambda email: not email_to_committer_map.get(email), emails)
     102        return [email for email in emails if not email_to_committer_map.get(email)]
    97103
    98104    def check_for_emails_missing_from_list(self, committer_list):
     
    212218
    213219    def _fill_in_emails_for_old_logins(self):
    214         authors_missing_email = filter(lambda author: author.find('@') == -1, self._last_commit_time_by_author_cache)
    215         authors_with_email = filter(lambda author: author.find('@') != -1, self._last_commit_time_by_author_cache)
    216         prefixes_of_authors_with_email = map(lambda author: author.split('@')[0], authors_with_email)
     220        authors_missing_email = [author for author in self._last_commit_time_by_author_cache if author.find('@') == -1]
     221        authors_with_email = [author for author in self._last_commit_time_by_author_cache if author.find('@') != -1]
     222        prefixes_of_authors_with_email = [author.split('@')[0] for author in authors_with_email]
    217223
    218224        for author in authors_missing_email:
     
    246252    @staticmethod
    247253    def _print_three_column_row(widths, values):
    248         print "%s%s%s" % (values[0].ljust(widths[0]), values[1].ljust(widths[1]), values[2])
     254        print("%s%s%s" % (values[0].ljust(widths[0]), values[1].ljust(widths[1]), values[2]))
    249255
    250256    def possibly_expired_committers(self, committer_list):
    251         authors_and_last_commits = self._last_commit_by_author().items()
     257        authors_and_last_commits = list(self._last_commit_by_author().items())
    252258        authors_and_last_commits.sort(lambda a,b: cmp(a[1], b[1]), reverse=True)
    253259        committer_cutof = date.today() - timedelta(days=365)
     
    285291        retired_authors_and_last_commits = self.possibly_expired_committers(committer_list)
    286292        column_widths = [13, 25]
    287         print
    288         print "Committers who have not committed within one year:"
     293        print()
     294        print("Committers who have not committed within one year:")
    289295        self._print_three_column_row(column_widths, ("Last Commit", "Committer Email", "Committer Record"))
    290296        for (author, last_commit) in retired_authors_and_last_commits:
     
    297303       
    298304        column_widths = [13, 25]
    299         print
    300         print "Reviewers who have not reviewed within one year:"
     305        print()
     306        print("Reviewers who have not reviewed within one year:")
    301307        for contributor in inactive_reviewers:
    302             print "\"{}\" {}".format(contributor.full_name.encode("utf-8"), contributor.bugzilla_email())
     308            print("\"{}\" {}".format(contributor.full_name.encode("utf-8"), contributor.bugzilla_email()))
    303309
    304310    def print_committers_missing_from_committer_list(self, committer_list):
     
    329335
    330336    def print_committers_with_invalid_bugzilla_emails(self, committer_list):
    331         print # Print a newline before we start hitting bugzilla (it logs about logging in).
    332         print "Checking committer emails against bugzilla (this will take a long time)"
    333         committers_with_invalid_bugzilla_email = filter(self._has_invalid_bugzilla_email, committer_list.committers())
     337        print() # Print a newline before we start hitting bugzilla (it logs about logging in).
     338        print("Checking committer emails against bugzilla (this will take a long time)")
     339        committers_with_invalid_bugzilla_email = list(filter(self._has_invalid_bugzilla_email, committer_list.committers()))
    334340        print_list_if_non_empty("Committers with invalid bugzilla email:", committers_with_invalid_bugzilla_email)
    335341
     
    342348        return "<{0}@268f45cc-cd09-0410-ab3c-d52691b4dbfc>".format(email)       
    343349
    344     email_to_legacy_username = dict(map(reversed, CommitterListFromGit.login_to_email_address.items()))
     350    email_to_legacy_username = dict(list(map(reversed, list(CommitterListFromGit.login_to_email_address.items()))))
    345351    def map_emails_to_legacy_username(emails):
    346352        legacy_username = None
     
    360366
    361367        for other_email in other_emails:
    362             print full_name, format_email(canonical_email), format_email(other_email)
    363             print full_name, format_email(canonical_email), format_email_with_uuid(other_email)
     368            print(full_name, format_email(canonical_email), format_email(other_email))
     369            print(full_name, format_email(canonical_email), format_email_with_uuid(other_email))
    364370
    365371
     
    375381    committer_list = CommitterList()
    376382    if options.dump:
    377         print committer_list.as_json()
     383        print(committer_list.as_json())
    378384        return 0
    379385
     
    383389
    384390    if options.canonicalize:
    385         print "Updating contributors.json in-place..."
     391        print("Updating contributors.json in-place...")
    386392        committer_list.reformat_in_place()
    387         print "Done"
     393        print("Done")
    388394        return 0
    389395
     
    391397 
    392398    if not Git.in_working_directory("."):
    393         print """\n\nWARNING: validate-committer-lists requires a git checkout.
     399        print("""\n\nWARNING: validate-committer-lists requires a git checkout.
    394400The following checks are disabled:
    395401 - List of inactive committers
    396402 - List of inactive reviewers
    397403 - List of historical committers missing from contributors.json
    398 """
     404""")
    399405        return 1
    400406
Note: See TracChangeset for help on using the changeset viewer.