• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python grammar.pluralize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webkitpy.tool.grammar.pluralize函数的典型用法代码示例。如果您正苦于以下问题:Python pluralize函数的具体用法?Python pluralize怎么用?Python pluralize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pluralize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _print_counts

    def _print_counts(self, counters_by_email):
        def counter_cmp(a_tuple, b_tuple):
            # split the tuples
            # the second element is the "counter" structure
            _, a_counter = a_tuple
            _, b_counter = b_tuple

            count_result = cmp(a_counter['count'], b_counter['count'])
            if count_result:
                return -count_result
            return cmp(a_counter['latest_name'].lower(), b_counter['latest_name'].lower())

        for author_email, counter in sorted(counters_by_email.items(), counter_cmp):
            if author_email != counter['latest_email']:
                continue
            contributor = self._committer_list.contributor_by_email(author_email)
            author_name = counter['latest_name']
            patch_count = counter['count']
            counter['names'] = counter['names'] - set([author_name])
            counter['emails'] = counter['emails'] - set([author_email])

            alias_list = []
            for alias in counter['names']:
                alias_list.append(alias)
            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) + ")")
            else:
                print "CONTRIBUTOR: %s (%s) has %s" % (author_name, author_email, grammar.pluralize(patch_count, "reviewed patch"))
        return
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:31,代码来源:suggestnominations.py


示例2: print_one_line_summary

    def print_one_line_summary(self, total, expected, unexpected):
        """Print a one-line summary of the test run to stdout.

        Args:
          total: total number of tests run
          expected: number of expected results
          unexpected: number of unexpected results
        """
        if self.disabled('one-line-summary'):
            return

        incomplete = total - expected - unexpected
        incomplete_str = ''
        if incomplete:
            self._write("")
            incomplete_str = " (%d didn't run)" % incomplete

        if unexpected == 0:
            if expected == total:
                if expected > 1:
                    self._write("All %d tests ran as expected." % expected)
                else:
                    self._write("The test ran as expected.")
            else:
                self._write("%s ran as expected%s." % (grammar.pluralize('test', expected), incomplete_str))
        else:
            self._write("%s ran as expected, %d didn't%s:" % (grammar.pluralize('test', expected), unexpected, incomplete_str))
        self._write("")
开发者ID:kseo,项目名称:webkit,代码行数:28,代码来源:printing.py


示例3: print_workers_and_shards

 def print_workers_and_shards(self, num_workers, num_shards):
     driver_name = self._port.driver_name()
     if num_workers == 1:
         self._print_default("Running 1 %s." % driver_name)
         self._print_debug("(%s)." % grammar.pluralize(num_shards, "shard"))
     else:
         self._print_default("Running %s in parallel." % (grammar.pluralize(num_workers, driver_name)))
         self._print_debug("(%d shards)." % num_shards)
     self._print_default('')
开发者ID:edcwconan,项目名称:webkit,代码行数:9,代码来源:printing.py


示例4: check_arguments_and_execute

 def check_arguments_and_execute(self, options, args, tool=None):
     if len(args) < len(self.required_arguments):
         log("%s required, %s provided.  Provided: %s  Required: %s\nSee '%s help %s' for usage." % (
             pluralize("argument", len(self.required_arguments)),
             pluralize("argument", len(args)),
             "'%s'" % " ".join(args),
             " ".join(self.required_arguments),
             tool.name(),
             self.name))
         return 1
     return self.execute(options, args, tool) or 0
开发者ID:achellies,项目名称:WinCEWebKit,代码行数:11,代码来源:multicommandtool.py


示例5: print_workers_and_shards

    def print_workers_and_shards(self, num_workers, num_shards):
        driver_name = self._port.driver_name()

        device_suffix = ' for device "{}"'.format(self._options.device_class) if self._options.device_class else ''
        if num_workers == 1:
            self._print_default('Running 1 {}{}.'.format(driver_name, device_suffix))
            self._print_debug('({}).'.format(grammar.pluralize(num_shards, "shard")))
        else:
            self._print_default('Running {} in parallel{}.'.format(grammar.pluralize(num_workers, driver_name), device_suffix))
            self._print_debug('({} shards).'.format(num_shards))
        self._print_default('')
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:11,代码来源:printing.py


示例6: _fetch_list_of_patches_to_process

 def _fetch_list_of_patches_to_process(self, options, args, tool):
     all_patches = []
     for bug_id in args:
         patches = tool.bugs.fetch_bug(bug_id).reviewed_patches()
         log("%s found on bug %s." % (pluralize("reviewed patch", len(patches)), bug_id))
         all_patches += patches
     return all_patches
开发者ID:Andersbakken,项目名称:check-coding-style,代码行数:7,代码来源:download.py


示例7: print_found

 def print_found(self, num_all_test_files, num_to_run, repeat_each, iterations):
     num_unique_tests = num_to_run / (repeat_each * iterations)
     found_str = 'Found %s; running %d' % (grammar.pluralize('test', num_all_test_files), num_unique_tests)
     if repeat_each * iterations > 1:
         found_str += ' (%d times each: --repeat-each=%d --iterations=%d)' % (repeat_each * iterations, repeat_each, iterations)
     found_str += ', skipping %d' % (num_all_test_files - num_unique_tests)
     self._print_default(found_str + '.')
开发者ID:kcomkar,项目名称:webkit,代码行数:7,代码来源:printing.py


示例8: feed

 def feed(self):
     ids_needing_review = set(self._tool.bugs.queries.fetch_attachment_ids_from_review_queue())
     new_ids = ids_needing_review.difference(self._ids_sent_to_server)
     log("Feeding EWS (%s, %s new)" % (pluralize("r? patch", len(ids_needing_review)), len(new_ids)))
     for attachment_id in new_ids:  # Order doesn't really matter for the EWS.
         self._tool.status_server.submit_to_ews(attachment_id)
         self._ids_sent_to_server.add(attachment_id)
开发者ID:Moondee,项目名称:Artemis,代码行数:7,代码来源:feeders.py


示例9: _print_one_line_summary

    def _print_one_line_summary(self, total_time, run_results):
        if self._options.timing:
            parallel_time = sum(result.total_run_time for result in run_results.results_by_name.values())

            # There is serial overhead in layout_test_runner.run() that we can't easily account for when
            # really running in parallel, but taking the min() ensures that in the worst case
            # (if parallel time is less than run_time) we do account for it.
            serial_time = total_time - min(run_results.run_time, parallel_time)

            speedup = (parallel_time + serial_time) / total_time
            timing_summary = ' in %.2fs (%.2fs in rwt, %.2gx)' % (total_time, serial_time, speedup)
        else:
            timing_summary = ''

        total = run_results.total - run_results.expected_skips
        expected = run_results.expected - run_results.expected_skips
        unexpected = run_results.unexpected
        incomplete = total - expected - unexpected
        incomplete_str = ''
        if incomplete:
            self._print_default("")
            incomplete_str = " (%d didn't run)" % incomplete

        if self._options.verbose or self._options.debug_rwt_logging or unexpected:
            self.writeln("")

        expected_summary_str = ''
        if run_results.expected_failures > 0:
            expected_summary_str = " (%d passed, %d didn't)" % (
                expected - run_results.expected_failures, run_results.expected_failures)

        summary = ''
        if unexpected == 0:
            if expected == total:
                if expected > 1:
                    summary = "All %d tests ran as expected%s%s." % (expected, expected_summary_str, timing_summary)
                else:
                    summary = "The test ran as expected%s%s." % (expected_summary_str, timing_summary)
            else:
                summary = "%s ran as expected%s%s%s." % (grammar.pluralize(
                    'test', expected), expected_summary_str, incomplete_str, timing_summary)
        else:
            summary = "%s ran as expected%s, %d didn't%s%s:" % (grammar.pluralize(
                'test', expected), expected_summary_str, unexpected, incomplete_str, timing_summary)

        self._print_quiet(summary)
        self._print_quiet("")
开发者ID:mirror,项目名称:chromium,代码行数:47,代码来源:printing.py


示例10: print_workers_and_shards

 def print_workers_and_shards(self, num_workers, num_shards, num_locked_shards):
     driver_name = self._port.driver_name()
     if num_workers == 1:
         self._print_default("Running 1 %s over %s." % (driver_name, grammar.pluralize('shard', num_shards)))
     else:
         self._print_default("Running %d %ss in parallel over %d shards (%d locked)." %
             (num_workers, driver_name, num_shards, num_locked_shards))
     self._print_default('')
开发者ID:kcomkar,项目名称:webkit,代码行数:8,代码来源:printing.py


示例11: _guess_reviewer_from_bug

 def _guess_reviewer_from_bug(self, bug_id):
     patches = self._tool.bugs.fetch_bug(bug_id).reviewed_patches()
     if len(patches) != 1:
         log("%s on bug %s, cannot infer reviewer." % (pluralize("reviewed patch", len(patches)), bug_id))
         return None
     patch = patches[0]
     log("Guessing \"%s\" as reviewer from attachment %s on bug %s." % (patch.reviewer().full_name, patch.id(), bug_id))
     return patch.reviewer().full_name
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:8,代码来源:updatechangelogswithreviewer.py


示例12: print_workers_and_shards

 def print_workers_and_shards(self, num_workers, num_shards, num_locked_shards):
     driver_name = self._port.driver_name()
     if num_workers == 1:
         self._print_default("Running 1 %s." % driver_name)
         self._print_debug("(%s)." % grammar.pluralize("shard", num_shards))
     else:
         self._print_default("Running %d %ss in parallel." % (num_workers, driver_name))
         self._print_debug("(%d shards; %d locked)." % (num_shards, num_locked_shards))
     self._print_default("")
开发者ID:EQ4,项目名称:h5vcc,代码行数:9,代码来源:printing.py


示例13: run_tests

    def run_tests(
        self,
        expectations,
        test_inputs,
        tests_to_skip,
        num_workers,
        needs_http,
        needs_websockets,
        needs_web_platform_test_server,
        retrying,
    ):
        self._expectations = expectations
        self._test_inputs = test_inputs
        self._needs_http = needs_http
        self._needs_websockets = needs_websockets
        self._needs_web_platform_test_server = needs_web_platform_test_server
        self._retrying = retrying

        # FIXME: rename all variables to test_run_results or some such ...
        run_results = TestRunResults(self._expectations, len(test_inputs) + len(tests_to_skip))
        self._current_run_results = run_results
        self._printer.num_tests = len(test_inputs)
        self._printer.num_started = 0

        if not retrying:
            self._printer.print_expected(run_results, self._expectations.model().get_tests_with_result_type)

        for test_name in set(tests_to_skip):
            result = test_results.TestResult(test_name)
            result.type = test_expectations.SKIP
            run_results.add(result, expected=True, test_is_slow=self._test_is_slow(test_name))

        self._printer.write_update("Sharding tests ...")
        all_shards = self._sharder.shard_tests(
            test_inputs, int(self._options.child_processes), self._options.fully_parallel
        )

        if (self._needs_http and self._options.http) or self._needs_web_platform_test_server:
            self.start_servers()

        num_workers = min(num_workers, len(all_shards))
        self._printer.print_workers_and_shards(num_workers, len(all_shards))

        if self._options.dry_run:
            return run_results

        self._printer.write_update("Starting %s ..." % grammar.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:
                pool.run(("test_list", shard.name, shard.test_inputs) for shard in all_shards)
        except TestRunInterruptedException, e:
            _log.warning(e.reason)
            run_results.interrupted = True
开发者ID:fanghongjia,项目名称:JavaScriptCore,代码行数:56,代码来源:layout_test_runner.py


示例14: run

 def run(self, state):
     if not self._options.obsolete_patches:
         return
     bug_id = state["bug_id"]
     patches = self._tool.bugs.fetch_bug(bug_id).patches()
     if not patches:
         return
     log("Obsoleting %s on bug %s" % (pluralize("old patch", len(patches)), bug_id))
     for patch in patches:
         self._tool.bugs.obsolete_attachment(patch.id())
开发者ID:mikezit,项目名称:Webkit_Code,代码行数:10,代码来源:obsoletepatches.py


示例15: _num_workers

 def _num_workers(self, num_shards):
     num_workers = min(int(self._options.child_processes), num_shards)
     driver_name = self._port.driver_name()
     if num_workers == 1:
         self._printer.print_config("Running 1 %s over %s" %
             (driver_name, grammar.pluralize('shard', num_shards)))
     else:
         self._printer.print_config("Running %d %ss in parallel over %d shards" %
             (num_workers, driver_name, num_shards))
     return num_workers
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:10,代码来源:test_runner.py


示例16: run_tests

    def run_tests(self, expectations, test_inputs, tests_to_skip, num_workers, needs_http, needs_websockets, retrying):
        self._expectations = expectations
        self._test_inputs = test_inputs
        self._needs_http = needs_http
        self._needs_websockets = needs_websockets
        self._retrying = retrying

        # FIXME: rename all variables to test_run_results or some such ...
        run_results = TestRunResults(self._expectations, len(test_inputs) + len(tests_to_skip))
        self._current_run_results = run_results
        self._remaining_locked_shards = []
        self._has_http_lock = False
        self._printer.num_tests = len(test_inputs)
        self._printer.num_started = 0

        if not retrying:
            self._printer.print_expected(run_results, self._expectations.get_tests_with_result_type)

        for test_name in set(tests_to_skip):
            result = test_results.TestResult(test_name)
            result.type = test_expectations.SKIP
            run_results.add(result, expected=True, test_is_slow=self._test_is_slow(test_name))

        self._printer.write_update('Sharding tests ...')
        locked_shards, unlocked_shards = self._sharder.shard_tests(test_inputs, int(self._options.child_processes), self._options.fully_parallel)

        # FIXME: We don't have a good way to coordinate the workers so that
        # they don't try to run the shards that need a lock if we don't actually
        # have the lock. The easiest solution at the moment is to grab the
        # lock at the beginning of the run, and then run all of the locked
        # shards first. This minimizes the time spent holding the lock, but
        # means that we won't be running tests while we're waiting for the lock.
        # If this becomes a problem in practice we'll need to change this.

        all_shards = locked_shards + unlocked_shards
        self._remaining_locked_shards = locked_shards
        if locked_shards and self._options.http:
            self.start_servers_with_lock(2 * min(num_workers, len(locked_shards)))

        num_workers = min(num_workers, len(all_shards))
        self._printer.print_workers_and_shards(num_workers, len(all_shards), len(locked_shards))

        if self._options.dry_run:
            return run_results

        self._printer.write_update('Starting %s ...' % grammar.pluralize('worker', num_workers))

        try:
            with message_pool.get(self, self._worker_factory, num_workers, self._port.worker_startup_delay_secs(), self._port.host) as pool:
                pool.run(('test_list', shard.name, shard.test_inputs) for shard in all_shards)
        except TestRunInterruptedException, e:
            _log.warning(e.reason)
            run_results.interrupted = True
开发者ID:3163504123,项目名称:phantomjs,代码行数:53,代码来源:layout_test_runner.py


示例17: test_pluralize

 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")
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:7,代码来源:grammar_unittest.py


示例18: run_tests

    def run_tests(self, expectations, test_inputs, tests_to_skip, num_workers, retry_attempt):
        self._expectations = expectations
        self._test_inputs = test_inputs
        self._retry_attempt = retry_attempt
        self._shards_to_redo = []

        # FIXME: rename all variables to test_run_results or some such ...
        run_results = TestRunResults(self._expectations, len(test_inputs) + len(tests_to_skip))
        self._current_run_results = run_results
        self._printer.num_tests = len(test_inputs)
        self._printer.num_completed = 0

        if retry_attempt < 1:
            self._printer.print_expected(run_results, self._expectations.get_tests_with_result_type)

        for test_name in set(tests_to_skip):
            result = test_results.TestResult(test_name)
            result.type = test_expectations.SKIP
            run_results.add(result, expected=True, test_is_slow=self._test_is_slow(test_name))

        self._printer.write_update('Sharding tests ...')
        locked_shards, unlocked_shards = self._sharder.shard_tests(test_inputs,
            int(self._options.child_processes), self._options.fully_parallel,
            self._options.run_singly or (self._options.batch_size == 1))

        # We don't have a good way to coordinate the workers so that they don't
        # try to run the shards that need a lock. The easiest solution is to
        # run all of the locked shards first.
        all_shards = locked_shards + unlocked_shards
        num_workers = min(num_workers, len(all_shards))

        if retry_attempt < 1:
            self._printer.print_workers_and_shards(num_workers, len(all_shards), len(locked_shards))

        if self._options.dry_run:
            return run_results

        self._printer.write_update('Starting %s ...' % grammar.pluralize('worker', num_workers))

        start_time = time.time()
        try:
            with message_pool.get(self, self._worker_factory, num_workers, self._port.host) as pool:
                pool.run(('test_list', shard.name, shard.test_inputs) for shard in all_shards)

            if self._shards_to_redo:
                num_workers -= len(self._shards_to_redo)
                if num_workers > 0:
                    with message_pool.get(self, self._worker_factory, num_workers, self._port.host) as pool:
                        pool.run(('test_list', shard.name, shard.test_inputs) for shard in self._shards_to_redo)
        except TestRunInterruptedException, e:
            _log.warning(e.reason)
            run_results.interrupted = True
开发者ID:dreifachstein,项目名称:chromium-src,代码行数:52,代码来源:layout_test_runner.py


示例19: _check_diff_failure

    def _check_diff_failure(self, error_log, tool):
        if not error_log:
            return None

        revert_failure_message_start = error_log.find("Failed to apply reverse diff for revision")
        if revert_failure_message_start == -1:
            return None

        lines = error_log[revert_failure_message_start:].split('\n')[1:]
        files = list(itertools.takewhile(lambda line: tool.filesystem.exists(tool.scm().absolute_path(line)), lines))
        if files:
            return "Failed to apply reverse diff for %s: %s" % (pluralize(len(files), "file", showCount=False), ", ".join(files))
        return None
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:13,代码来源:irc_command.py


示例20: _message_for_revert

 def _message_for_revert(cls, revision_list, reason, description_list, reverted_bug_url_list, rollout_bug_url=None):
     message = "Unreviewed, rolling out %s.\n" % grammar.join_with_separators(['r' + str(revision) for revision in revision_list])
     if rollout_bug_url:
         message += "%s\n" % rollout_bug_url
     message += "\n"
     if reason:
         message += "%s\n" % reason
     message += "\n"
     message += "Reverted %s:\n\n" % grammar.pluralize(len(revision_list), "changeset", showCount=False)
     for index in range(len(revision_list)):
         if description_list[index]:
             message += "\"%s\"\n" % description_list[index]
         if reverted_bug_url_list[index]:
             message += "%s\n" % reverted_bug_url_list[index]
         message += "%s\n\n" % urls.view_revision_url(revision_list[index])
     return message
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:16,代码来源:preparechangelogforrevert.py



注:本文中的webkitpy.tool.grammar.pluralize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mocktool.MockOptions类代码示例发布时间:2022-05-26
下一篇:
Python grammar.join_with_separators函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap