Title: [277735] trunk/Tools
Revision
277735
Author
jbed...@apple.com
Date
2021-05-19 11:09:45 -0700 (Wed, 19 May 2021)

Log Message

[webkitpy] Deprecate webkitpy/tool/grammar.py
https://bugs.webkit.org/show_bug.cgi?id=225943
<rdar://problem/78180111>

Reviewed by Stephanie Lewis.

* Scripts/bisect-builds:
* Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
(LayoutTestRunner.run_tests):
* Scripts/webkitpy/layout_tests/controllers/manager.py:
* Scripts/webkitpy/layout_tests/views/printing.py:
(Printer.print_found):
(Printer.print_workers_and_shards):
(Printer._print_one_line_summary):
* Scripts/webkitpy/test/printer.py:
* Scripts/webkitpy/tool/bot/flakytestreporter.py:
(FlakyTestReporter._lookup_bug_for_flaky_test):
(FlakyTestReporter._create_bug_for_flaky_test):
* Scripts/webkitpy/tool/commands/download.py:
(AbstractPatchProcessingCommand.execute):
(ProcessBugsMixin._fetch_list_of_patches_to_process):
(ProcessURLsMixin._fetch_list_of_patches_to_process):
* Scripts/webkitpy/tool/commands/download_unittest.py:
* Scripts/webkitpy/tool/commands/queries.py:
* Scripts/webkitpy/tool/commands/suggestnominations.py:
(SuggestNominations._print_nominations):
(SuggestNominations._print_counts):
* Scripts/webkitpy/tool/commands/upload.py:
(CleanPendingCommit._flags_to_clear_on_patch):
(PostCommits.execute):
* Scripts/webkitpy/tool/grammar.py: Removed.
* Scripts/webkitpy/tool/grammar_unittest.py: Removed.
* Scripts/webkitpy/tool/multicommandtool.py:
* Scripts/webkitpy/tool/steps/obsoletepatches.py:
(ObsoletePatches.run):
* Scripts/webkitpy/tool/steps/preparechangelogforrevert.py:
(PrepareChangeLogForRevert._message_for_revert):
* Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py:
* Scripts/webkitpy/tool/steps/reopenbugafterrevert.py:
(ReopenBugAfterRevert.run):

Modified Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (277734 => 277735)


--- trunk/Tools/ChangeLog	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/ChangeLog	2021-05-19 18:09:45 UTC (rev 277735)
@@ -1,3 +1,46 @@
+2021-05-19  Jonathan Bedard  <jbed...@apple.com>
+
+        [webkitpy] Deprecate webkitpy/tool/grammar.py
+        https://bugs.webkit.org/show_bug.cgi?id=225943
+        <rdar://problem/78180111>
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/bisect-builds:
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
+        (LayoutTestRunner.run_tests):
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        * Scripts/webkitpy/layout_tests/views/printing.py:
+        (Printer.print_found):
+        (Printer.print_workers_and_shards):
+        (Printer._print_one_line_summary):
+        * Scripts/webkitpy/test/printer.py:
+        * Scripts/webkitpy/tool/bot/flakytestreporter.py:
+        (FlakyTestReporter._lookup_bug_for_flaky_test):
+        (FlakyTestReporter._create_bug_for_flaky_test):
+        * Scripts/webkitpy/tool/commands/download.py:
+        (AbstractPatchProcessingCommand.execute):
+        (ProcessBugsMixin._fetch_list_of_patches_to_process):
+        (ProcessURLsMixin._fetch_list_of_patches_to_process):
+        * Scripts/webkitpy/tool/commands/download_unittest.py:
+        * Scripts/webkitpy/tool/commands/queries.py:
+        * Scripts/webkitpy/tool/commands/suggestnominations.py:
+        (SuggestNominations._print_nominations):
+        (SuggestNominations._print_counts):
+        * Scripts/webkitpy/tool/commands/upload.py:
+        (CleanPendingCommit._flags_to_clear_on_patch):
+        (PostCommits.execute):
+        * Scripts/webkitpy/tool/grammar.py: Removed.
+        * Scripts/webkitpy/tool/grammar_unittest.py: Removed.
+        * Scripts/webkitpy/tool/multicommandtool.py:
+        * Scripts/webkitpy/tool/steps/obsoletepatches.py:
+        (ObsoletePatches.run):
+        * Scripts/webkitpy/tool/steps/preparechangelogforrevert.py:
+        (PrepareChangeLogForRevert._message_for_revert):
+        * Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py:
+        * Scripts/webkitpy/tool/steps/reopenbugafterrevert.py:
+        (ReopenBugAfterRevert.run):
+
 2021-05-19  Jonathan Bedard  <jonwbed...@gmail.com>
 
         [webkitscmpy] Apply logging options to every command

Modified: trunk/Tools/Scripts/bisect-builds (277734 => 277735)


--- trunk/Tools/Scripts/bisect-builds	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/bisect-builds	2021-05-19 18:09:45 UTC (rev 277735)
@@ -30,8 +30,9 @@
 from webkitpy.common.memoized import memoized
 from webkitpy.common.system.systemhost import SystemHost
 from webkitpy.common.version_name_map import VersionNameMap
-from webkitpy.tool.grammar import pluralize
 
+from webkitcorepy.string_utils import pluralize
+
 import argparse
 import bisect
 import json

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -31,6 +31,8 @@
 import threading
 import time
 
+from webkitcorepy.string_utils import pluralize
+
 from webkitpy.common import message_pool
 from webkitpy.common.iteration_compatibility import iteritems
 from webkitpy.layout_tests.controllers import single_test_runner
@@ -38,7 +40,6 @@
 from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.models import test_failures
 from webkitpy.layout_tests.models import test_results
-from webkitpy.tool import grammar
 
 
 _log = logging.getLogger(__name__)
@@ -114,7 +115,7 @@
         if self._options.dry_run:
             return run_results
 
-        self._printer.write_update('Starting %s ...' % grammar.pluralize(num_workers, "worker"))
+        self._printer.write_update('Starting %s ...' % pluralize(num_workers, "worker"))
 
         try:
             with message_pool.get(self, self._worker_factory, num_workers, self._port.worker_startup_delay_secs(), self._port.host) as pool:

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -42,6 +42,8 @@
 import time
 from collections import defaultdict, OrderedDict
 
+from webkitcorepy.string_utils import pluralize
+
 from webkitpy.common.iteration_compatibility import iteritems, itervalues
 from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
 from webkitpy.layout_tests.controllers.layout_test_runner import LayoutTestRunner
@@ -54,7 +56,6 @@
 from webkitpy.layout_tests.models import test_run_results
 from webkitpy.layout_tests.models.test_input import TestInput
 from webkitpy.layout_tests.models.test_run_results import INTERRUPTED_EXIT_STATUS, TestRunResults
-from webkitpy.tool.grammar import pluralize
 from webkitpy.results.upload import Upload
 from webkitpy.xcode.device_type import DeviceType
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -31,7 +31,8 @@
 import math
 import optparse
 
-from webkitpy.tool import grammar
+from webkitcorepy.string_utils import pluralize
+
 from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.views.metered_stream import MeteredStream
 
@@ -107,9 +108,9 @@
         self._print_default('')
 
     def print_found(self, num_all_test_files, num_to_run, repeat_each, iterations):
-        found_str = 'Found %s; running %d' % (grammar.pluralize(num_all_test_files, "test"), num_to_run)
+        found_str = 'Found %s; running %d' % (pluralize(num_all_test_files, "test"), num_to_run)
         if repeat_each * iterations > 1:
-            found_str += ' (%s each: --repeat-each=%d --iterations=%d)' % (grammar.pluralize(repeat_each * iterations, "time"), repeat_each, iterations)
+            found_str += ' (%s each: --repeat-each=%d --iterations=%d)' % (pluralize(repeat_each * iterations, "time"), repeat_each, iterations)
         found_str += ', skipping %d' % (num_all_test_files - num_to_run)
         self._print_default(found_str + '.')
 
@@ -124,9 +125,9 @@
 
         if num_workers == 1:
             self._print_default('Running 1 {}.'.format(driver_name))
-            self._print_debug('({}).'.format(grammar.pluralize(num_shards, "shard")))
+            self._print_debug('({}).'.format(pluralize(num_shards, "shard")))
         else:
-            self._print_default('Running {} in parallel.'.format(grammar.pluralize(num_workers, driver_name)))
+            self._print_default('Running {} in parallel.'.format(pluralize(num_workers, driver_name)))
             self._print_debug('({} shards).'.format(num_shards))
         self._print_default('')
 
@@ -290,9 +291,9 @@
                 else:
                     summary = "The test ran as expected."
             else:
-                summary = "%s ran as expected%s." % (grammar.pluralize(expected, "test"), incomplete_str)
+                summary = "%s ran as expected%s." % (pluralize(expected, "test"), incomplete_str)
         else:
-            summary = "%s ran as expected, %d didn't%s:" % (grammar.pluralize(expected, "test"), unexpected, incomplete_str)
+            summary = "%s ran as expected, %d didn't%s:" % (pluralize(expected, "test"), unexpected, incomplete_str)
 
         self._print_quiet(summary)
         self._print_quiet("")

Modified: trunk/Tools/Scripts/webkitpy/test/printer.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/test/printer.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/test/printer.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -23,9 +23,10 @@
 
 import logging
 
+from webkitcorepy.string_utils import pluralize
+
 from webkitpy.common.system.systemhost import SystemHost
 from webkitpy.layout_tests.views.metered_stream import MeteredStream
-from webkitpy.tool.grammar import pluralize
 
 _log = logging.getLogger(__name__)
 

Modified: trunk/Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -29,11 +29,13 @@
 import logging
 import os.path
 
+from webkitcorepy import string_utils
+
 from webkitpy.common.net.layouttestresults import path_for_layout_test
 from webkitpy.common.config import urls
 from webkitpy.tool.bot.botinfo import BotInfo
-from webkitpy.tool.grammar import plural, pluralize, join_with_separators
 
+
 _log = logging.getLogger(__name__)
 
 
@@ -78,7 +80,7 @@
         if len(bugs) > 1:
             # FIXME: There are probably heuristics we could use for finding
             # the right bug instead of the first, like open vs. closed.
-            _log.warn("Found %s %s matching '%s' filed by a bot, using the first." % (pluralize(len(bugs), "bug"), [bug.id() for bug in bugs], flaky_test))
+            _log.warn("Found %s %s matching '%s' filed by a bot, using the first." % (string_utils.pluralize(len(bugs), "bug"), [bug.id() for bug in bugs], flaky_test))
         return bugs[0]
 
     def _view_source_url_for_test(self, test_path):
@@ -87,7 +89,7 @@
     def _create_bug_for_flaky_test(self, flaky_test, author_emails, latest_flake_message):
         format_values = {
             'test': flaky_test,
-            'authors': join_with_separators(sorted(author_emails)),
+            'authors': string_utils.join(sorted(author_emails)),
             'flake_message': latest_flake_message,
             'test_url': self._view_source_url_for_test(flaky_test),
             'bot_name': self._bot_name,
@@ -118,8 +120,8 @@
     def _optional_author_string(self, author_emails):
         if not author_emails:
             return ""
-        heading_string = plural('author') if len(author_emails) > 1 else 'author'
-        authors_string = join_with_separators(sorted(author_emails))
+        heading_string = 'authors' if len(author_emails) > 1 else 'author'
+        authors_string = string_utils.join(sorted(author_emails))
         return " (%s: %s)" % (heading_string, authors_string)
 
     def _latest_flake_message(self, flaky_result, patch):

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/download.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/commands/download.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/download.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -31,6 +31,8 @@
 
 from webkitpy.tool import steps
 
+from webkitcorepy.string_utils import pluralize
+
 from webkitpy.common.checkout.changelog import ChangeLog
 from webkitpy.common.config import urls
 from webkitpy.common.net.bugzilla import Bugzilla
@@ -39,7 +41,6 @@
 from webkitpy.tool.commands.deprecatedcommand import DeprecatedCommand
 from webkitpy.tool.commands.stepsequence import StepSequence
 from webkitpy.tool.comments import bug_comment_from_commit_text
-from webkitpy.tool.grammar import pluralize
 from webkitpy.tool.multicommandtool import Command
 
 _log = logging.getLogger(__name__)
@@ -174,7 +175,7 @@
 
         # It's nice to print out total statistics.
         bugs_to_patches = self._collect_patches_by_bug(patches)
-        _log.info("Processing %s from %s." % (pluralize(len(patches), "patch"), pluralize(len(bugs_to_patches), "bug")))
+        _log.info("Processing %s from %s." % (pluralize(len(patches), 'patch', plural='patches'), pluralize(len(bugs_to_patches), "bug")))
 
         for patch in patches:
             self._process_patch(patch, options, args, tool)
@@ -218,13 +219,13 @@
         all_patches = []
         for bug_id in args:
             patches = tool.bugs.fetch_bug(bug_id).reviewed_patches()
-            _log.info("%s found on bug %s." % (pluralize(len(patches), "reviewed patch"), bug_id))
+            _log.info("%s found on bug %s." % (pluralize(len(patches), 'reviewed patch', plural='reviewed patches'), bug_id))
             all_patches += patches
         if not all_patches:
             _log.info("No reviewed patches found, looking for unreviewed patches.")
             for bug_id in args:
                 patches = tool.bugs.fetch_bug(bug_id).patches()
-                _log.info("%s found on bug %s." % (pluralize(len(patches), "patch"), bug_id))
+                _log.info("%s found on bug %s." % (pluralize(len(patches), 'patch', plural='patches'), bug_id))
                 all_patches += patches
         return all_patches
 
@@ -236,7 +237,7 @@
             bug_id = urls.parse_bug_id(url)
             if bug_id:
                 patches = tool.bugs.fetch_bug(bug_id).patches()
-                _log.info("%s found on bug %s." % (pluralize(len(patches), "patch"), bug_id))
+                _log.info("%s found on bug %s." % (pluralize(len(patches), 'patch', plural='patches'), bug_id))
                 all_patches += patches
 
             attachment_id = urls.parse_attachment_id(url)

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -467,17 +467,17 @@
 Was that diff correct?
 Building WebKit
 Committed r49824: <https://commits.webkit.org/r49824>
-MOCK reopen_bug 50000 with comment 'Reverted r852, r963, and r3001 for reason:
+MOCK reopen_bug 50000 with comment 'Reverted r852, r963 and r3001 for reason:
 
 Reason
 
 Committed r49824 (5@main): <https://commits.webkit.org/5@main>'
-MOCK reopen_bug 50005 with comment 'Reverted r852, r963, and r3001 for reason:
+MOCK reopen_bug 50005 with comment 'Reverted r852, r963 and r3001 for reason:
 
 Reason
 
 Committed r49824 (5@main): <https://commits.webkit.org/5@main>'
-MOCK reopen_bug 50004 with comment 'Reverted r852, r963, and r3001 for reason:
+MOCK reopen_bug 50004 with comment 'Reverted r852, r963 and r3001 for reason:
 
 Reason
 
@@ -495,12 +495,12 @@
 Was that diff correct?
 Building WebKit
 Committed r49824: <https://commits.webkit.org/r49824>
-MOCK reopen_bug 50000 with comment 'Reverted r852, r963, and r999 for reason:
+MOCK reopen_bug 50000 with comment 'Reverted r852, r963 and r999 for reason:
 
 Reason
 
 Committed r49824 (5@main): <https://commits.webkit.org/5@main>'
-MOCK reopen_bug 50005 with comment 'Reverted r852, r963, and r999 for reason:
+MOCK reopen_bug 50005 with comment 'Reverted r852, r963 and r999 for reason:
 
 Reason
 

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queries.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -37,6 +37,8 @@
 from datetime import datetime
 from optparse import make_option
 
+from webkitcorepy.string_utils import pluralize
+
 from webkitpy.tool import steps
 
 import webkitpy.common.config.urls as config_urls
@@ -52,7 +54,6 @@
 from webkitpy.port import platform_options, configuration_options
 from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCommand
 from webkitpy.tool.commands.deprecatedcommand import DeprecatedCommand
-from webkitpy.tool.grammar import pluralize
 from webkitpy.tool.multicommandtool import Command
 
 _log = logging.getLogger(__name__)

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/suggestnominations.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/commands/suggestnominations.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/suggestnominations.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -30,9 +30,10 @@
 from optparse import make_option
 import re
 
+from webkitcorepy import string_utils
+
 from webkitpy.common.checkout.changelog import ChangeLogEntry
 from webkitpy.common.config.committers import CommitterList
-from webkitpy.tool import grammar
 from webkitpy.tool.multicommandtool import Command
 
 
@@ -249,7 +250,7 @@
 
         for nomination in nominations:
             # This is a little bit of a hack, but its convienent to just pass the nomination dictionary to the formating operator.
-            nomination['roles_string'] = grammar.join_with_separators(nomination['roles']).upper()
+            nomination['roles_string'] = string_utils.join(nomination['roles']).upper()
             print("%(roles_string)s: %(author_name)s (%(author_email)s) has %(patch_count)s reviewed patches" % nomination)
             counter = counters_by_email[nomination['author_email']]
 
@@ -274,9 +275,9 @@
             for alias in counter['emails']:
                 alias_list.append(alias)
             if alias_list:
-                print("CONTRIBUTOR: %s (%s) has %s %s" % (author_name, author_email, grammar.pluralize(patch_count, "reviewed patch"), "(aliases: " + ", ".join(alias_list) + ")"))
+                print("CONTRIBUTOR: %s (%s) has %s %s" % (author_name, author_email, string_utils.pluralize(patch_count, 'reviewed patch', plural='reviewed patches'), "(aliases: " + ", ".join(alias_list) + ")"))
             else:
-                print("CONTRIBUTOR: %s (%s) has %s" % (author_name, author_email, grammar.pluralize(patch_count, "reviewed patch")))
+                print("CONTRIBUTOR: %s (%s) has %s" % (author_name, author_email, string_utils.pluralize(patch_count, 'reviewed patch', plural='reviewed patches')))
         return
 
     def execute(self, options, args, tool):

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/upload.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/commands/upload.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/upload.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -36,6 +36,8 @@
 
 from webkitpy.tool import steps
 
+from webkitcorepy import string_utils
+
 from webkitpy.common.checkout.changelog import parse_bug_id_from_changelog
 from webkitpy.common.config.committers import CommitterList
 from webkitpy.common.system.user import User
@@ -42,7 +44,6 @@
 from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCommand
 from webkitpy.tool.commands.deprecatedcommand import DeprecatedCommand
 from webkitpy.tool.comments import bug_comment_from_svn_revision
-from webkitpy.tool.grammar import pluralize, join_with_separators
 from webkitpy.tool.multicommandtool import Command
 
 _log = logging.getLogger(__name__)
@@ -80,7 +81,7 @@
                 what_was_cleared.append(u"%s's review+" % patch.reviewer().full_name)
             else:
                 what_was_cleared.append("review+")
-        return join_with_separators(what_was_cleared)
+        return string_utils.join(what_was_cleared)
 
     def execute(self, options, args, tool):
         for bug_id in tool.bugs.queries.fetch_bug_ids_from_pending_commit_list():
@@ -347,7 +348,7 @@
     def execute(self, options, args, tool):
         commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
         if len(commit_ids) > 10:  # We could lower this limit, 10 is too many for one bug as-is.
-            _log.error("webkit-patch does not support attaching %s at once.  Are you sure you passed the right commit range?" % (pluralize(len(commit_ids), "patch")))
+            _log.error("webkit-patch does not support attaching %s at once.  Are you sure you passed the right commit range?" % (string_utils.pluralize(len(commit_ids), 'patch', plural='patches')))
             sys.exit(1)
 
         have_obsoleted_patches = set()

Deleted: trunk/Tools/Scripts/webkitpy/tool/grammar.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/grammar.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/grammar.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -1,57 +0,0 @@
-# Copyright (c) 2009 Google Inc. All rights reserved.
-# Copyright (c) 2009 Apple Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import re
-
-
-def plural(noun):
-    # This is a dumb plural() implementation that is just enough for our uses.
-    if re.search("h$", noun):
-        return noun + "es"
-    else:
-        return noun + "s"
-
-
-def pluralize(count, noun, showCount=True):
-    if count != 1:
-        noun = plural(noun)
-    if showCount:
-        return "%d %s" % (count, noun)
-    else:
-        return "%s" % noun
-
-
-def join_with_separators(list_of_strings, separator=', ', _only_two_separator_=" and ", last_separator=', and '):
-    if not list_of_strings:
-        return ""
-    if len(list_of_strings) == 1:
-        return list_of_strings[0]
-    if len(list_of_strings) == 2:
-        return only_two_separator.join(list_of_strings)
-    return "%s%s%s" % (separator.join(list_of_strings[:-1]), last_separator, list_of_strings[-1])

Deleted: trunk/Tools/Scripts/webkitpy/tool/grammar_unittest.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/grammar_unittest.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/grammar_unittest.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -1,53 +0,0 @@
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#    * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#    * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#    * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import unittest
-
-from webkitpy.tool.grammar import join_with_separators
-from webkitpy.tool.grammar import plural
-from webkitpy.tool.grammar import pluralize
-
-
-class GrammarTest(unittest.TestCase):
-
-    def test_join_with_separators(self):
-        self.assertEqual(join_with_separators(["one"]), "one")
-        self.assertEqual(join_with_separators(["one", "two"]), "one and two")
-        self.assertEqual(join_with_separators(["one", "two", "three"]), "one, two, and three")
-
-    def test_plural(self):
-        self.assertEqual(plural("patch"), "patches")
-        self.assertEqual(plural("test"), "tests")
-
-    def test_pluralize(self):
-        self.assertEqual(pluralize(1, "patch"), "1 patch")
-        self.assertEqual(pluralize(2, "patch"), "2 patches")
-        self.assertEqual(pluralize(1, "patch", True), "1 patch")
-        self.assertEqual(pluralize(2, "patch", True), "2 patches")
-        self.assertEqual(pluralize(1, "patch", False), "patch")
-        self.assertEqual(pluralize(2, "patch", False), "patches")

Modified: trunk/Tools/Scripts/webkitpy/tool/multicommandtool.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/multicommandtool.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/multicommandtool.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -36,7 +36,7 @@
 
 from optparse import OptionParser, IndentedHelpFormatter, SUPPRESS_USAGE, make_option
 
-from webkitpy.tool.grammar import pluralize
+from webkitcorepy.string_utils import pluralize
 
 _log = logging.getLogger(__name__)
 

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/obsoletepatches.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/steps/obsoletepatches.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/obsoletepatches.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -28,7 +28,8 @@
 
 import logging
 
-from webkitpy.tool.grammar import pluralize
+from webkitcorepy.string_utils import pluralize
+
 from webkitpy.tool.steps.abstractstep import AbstractStep
 from webkitpy.tool.steps.options import Options
 
@@ -49,6 +50,6 @@
         patches = self._tool.bugs.fetch_bug(bug_id).patches()
         if not patches:
             return
-        _log.info("Obsoleting %s on bug %s" % (pluralize(len(patches), "old patch"), bug_id))
+        _log.info("Obsoleting %s on bug %s" % (pluralize(len(patches), 'old patch', plural='old patches'), bug_id))
         for patch in patches:
             self._tool.bugs.obsolete_attachment(patch.id())

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -26,9 +26,10 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+from webkitcorepy import string_utils
+
 from webkitpy.common.checkout.changelog import ChangeLog
 from webkitpy.common.config import urls
-from webkitpy.tool import grammar
 from webkitpy.tool.steps.abstractstep import AbstractStep
 
 
@@ -35,7 +36,7 @@
 class PrepareChangeLogForRevert(AbstractStep):
     @classmethod
     def _message_for_revert(cls, revision_list, reason, description_list, reverted_bug_url_list, revert_bug_url=None):
-        message = "Unreviewed, reverting %s.\n" % grammar.join_with_separators(['r' + str(revision) for revision in revision_list])
+        message = "Unreviewed, reverting %s.\n" % string_utils.join(['r' + str(revision) for revision in revision_list])
         if revert_bug_url:
             message += "%s\n" % revert_bug_url
         message += "\n"
@@ -42,7 +43,7 @@
         if reason:
             message += "%s\n" % reason
         message += "\n"
-        message += "Reverted %s:\n\n" % grammar.pluralize(len(revision_list), "changeset", showCount=False)
+        message += "Reverted changeset%s:\n\n" % ('s' if len(revision_list) > 1 else '')
         for index in range(len(revision_list)):
             if description_list[index]:
                 message += "\"%s\"\n" % description_list[index]

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -63,7 +63,7 @@
 
     _multiple_revert_entry = '''2009-08-19  Eric Seidel  <e...@webkit.org>
 
-        Unreviewed, reverting r12345, r12346, and r12347.
+        Unreviewed, reverting r12345, r12346 and r12347.
 
         Reason
 
@@ -84,7 +84,7 @@
 
     _multiple_revert_entry_with_missing_bug_urls_and_descriptions = '''2009-08-19  Eric Seidel  <e...@webkit.org>
 
-        Unreviewed, reverting r12345, r12346, and r12347.
+        Unreviewed, reverting r12345, r12346 and r12347.
 
         Reason
 
@@ -99,7 +99,7 @@
 
     _multiple_revert_entry_with_a_missing_bug_url_and_description = '''2009-08-19  Eric Seidel  <e...@webkit.org>
 
-        Unreviewed, reverting r12345, r12346, and r12347.
+        Unreviewed, reverting r12345, r12346 and r12347.
 
         Reason
 
@@ -135,7 +135,7 @@
 
     _multiple_revert_entry_with_revert_bug_url = '''2009-08-19  Eric Seidel  <e...@webkit.org>
 
-        Unreviewed, reverting r12345, r12346, and r12347.
+        Unreviewed, reverting r12345, r12346 and r12347.
         http://revert.example.com/56789
 
         Reason

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/reopenbugafterrevert.py (277734 => 277735)


--- trunk/Tools/Scripts/webkitpy/tool/steps/reopenbugafterrevert.py	2021-05-19 18:09:30 UTC (rev 277734)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/reopenbugafterrevert.py	2021-05-19 18:09:45 UTC (rev 277735)
@@ -28,8 +28,9 @@
 
 import logging
 
+from webkitcorepy import string_utils
+
 from webkitpy.tool.comments import bug_comment_from_commit_text
-from webkitpy.tool.grammar import join_with_separators
 from webkitpy.tool.steps.abstractstep import AbstractStep
 
 _log = logging.getLogger(__name__)
@@ -38,7 +39,7 @@
 class ReopenBugAfterRevert(AbstractStep):
     def run(self, state):
         commit_comment = bug_comment_from_commit_text(self._tool.scm(), state["commit_text"])
-        revision_list = join_with_separators(['r' + str(revision) for revision in state["revision_list"]])
+        revision_list = string_utils.join(['r' + str(revision) for revision in state["revision_list"]])
         comment_text = "Reverted %s for reason:\n\n%s\n\n%s" % (revision_list, state["reason"], commit_comment)
         bug_ids = state["bug_id_list"]
         if not bug_ids:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to