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

Python console.colorize函数代码示例

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

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



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

示例1: test_acceptance

def test_acceptance(options):
    """
    Run the acceptance tests for the either lms or cms
    """
    opts = {
        'fasttest': getattr(options, 'fasttest', False),
        'system': getattr(options, 'system', None),
        'default_store': getattr(options, 'default_store', None),
        'verbosity': getattr(options, 'verbosity', 3),
        'extra_args': getattr(options, 'extra_args', ''),
        'pdb': getattr(options, 'pdb', False),
    }

    if opts['system'] not in ['cms', 'lms']:
        msg = colorize(
            'red',
            'No system specified, running tests for both cms and lms.'
        )
        print msg
    if opts['default_store'] not in ['draft', 'split']:
        msg = colorize(
            'red',
            'No modulestore specified, running tests for both draft and split.'
        )
        print msg

    suite = AcceptanceTestSuite('{} acceptance'.format(opts['system']), **opts)
    suite.run()
开发者ID:andela-ijubril,项目名称:edx-platform,代码行数:28,代码来源:acceptance_test.py


示例2: format_message

def format_message(status):
    sender = console.colorize('red', '@%s' % status.GetSenderScreenName())
    recipient = console.colorize('red', '@%s' % status.GetRecipientScreenName())
    date = console.colorize('blue', '\t\t%s' % status.GetCreatedAt())
    arrow = console.colorize('darkgray', ' -> ')
    text = console.colorize('black', '\t%s' % format_text(status.GetText()))
    return '\n'.join([sender + arrow + recipient + date, text])
开发者ID:PepeGuerrero,项目名称:LearningPython,代码行数:7,代码来源:tuitpy.py


示例3: __enter__

    def __enter__(self):
        super(BokChoyTestSuite, self).__enter__()

        # Ensure that we have a directory to put logs and reports
        self.log_dir.makedirs_p()
        self.har_dir.makedirs_p()
        self.report_dir.makedirs_p()
        test_utils.clean_reports_dir()

        if not (self.fasttest or self.skip_clean):
            test_utils.clean_test_files()

        msg = colorize('green', "Checking for mongo, memchache, and mysql...")
        print msg
        bokchoy_utils.check_services()

        if not self.testsonly:
            self.prepare_bokchoy_run()

        msg = colorize('green', "Confirming servers have started...")
        print msg
        bokchoy_utils.wait_for_test_servers()
        try:
            # Create course in order to seed forum data underneath. This is
            # a workaround for a race condition. The first time a course is created;
            # role permissions are set up for forums.
            CourseFixture('foobar_org', '1117', 'seed_forum', 'seed_foo').install()
            print 'Forums permissions/roles data has been seeded'
        except FixtureError:
            # this means it's already been done
            pass

        if self.serversonly:
            self.run_servers_continuously()
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:34,代码来源:bokchoy_suite.py


示例4: __init__

    def __init__(self, *args, **kwargs):
        super(SystemTestSuite, self).__init__(*args, **kwargs)
        self.test_id = kwargs.get('test_id', self._default_test_id)
        self.fasttest = kwargs.get('fasttest', False)

        self.processes = kwargs.get('processes', None)
        self.randomize = kwargs.get('randomize', None)
        self.settings = kwargs.get('settings', Env.TEST_SETTINGS)

        if self.processes is None:
            # Don't use multiprocessing by default
            self.processes = 0

        self.processes = int(self.processes)

        if self.randomize is None:
            self.randomize = self.root == 'lms'

        if self.processes != 0 and self.verbosity > 1:
            print colorize(
                'red',
                "The TestId module and multiprocessing module can't be run "
                "together in verbose mode. Disabling TestId for {} tests.".format(self.root)
            )
            self.use_ids = False
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:25,代码来源:nose_suite.py


示例5: get_test_course

    def get_test_course(self):
        """
        Fetches the test course.
        """
        self.imports_dir.makedirs_p()
        zipped_course = self.imports_dir + 'demo_course.tar.gz'

        msg = colorize('green', "Fetching the test course from github...")
        print msg

        sh(
            'wget {tar_gz_file} -O {zipped_course}'.format(
                tar_gz_file=self.tar_gz_file,
                zipped_course=zipped_course,
            )
        )

        msg = colorize('green', "Uncompressing the test course...")
        print msg

        sh(
            'tar zxf {zipped_course} -C {courses_dir}'.format(
                zipped_course=zipped_course,
                courses_dir=self.imports_dir,
            )
        )
开发者ID:AndreySonetico,项目名称:edx-platform,代码行数:26,代码来源:bokchoy_suite.py


示例6: __init__

    def __init__(self, *args, **kwargs):
        super(SystemTestSuite, self).__init__(*args, **kwargs)
        self.test_id = kwargs.get('test_id', self._default_test_id)
        self.fasttest = kwargs.get('fasttest', False)

        self.processes = kwargs.get('processes', None)
        self.randomize = kwargs.get('randomize', None)

        if self.processes is None:
            # Use one process per core for LMS tests, and no multiprocessing
            # otherwise.
            self.processes = 0

        self.processes = int(self.processes)

        if self.randomize is None:
            self.randomize = False

        if self.processes != 0 and self.verbosity > 1:
            print colorize(
                'red',
                "The TestId module and multiprocessing module can't be run "
                "together in verbose mode. Disabling TestId for {} tests.".format(self.root)
            )
            self.use_ids = False
开发者ID:Rosivania,项目名称:edx-platform,代码行数:25,代码来源:nose_suite.py


示例7: generate_optimized_static_assets

 def generate_optimized_static_assets(self):
     """
     Collect static assets using test_static_optimized.py which generates
     optimized files to a dedicated test static root.
     """
     print colorize("green", "Generating optimized static assets...")
     sh("paver update_assets --settings=test_static_optimized")
开发者ID:sigberto,项目名称:edx-platform,代码行数:7,代码来源:suite.py


示例8: report_test_results

    def report_test_results(self):
        """
        Writes a list of failed_suites to sys.stderr
        """
        if self.failed_suites:
            msg = colorize('red', "\n\n{bar}\nTests failed in the following suites:\n* ".format(bar="=" * 48))
            msg += colorize('red', '\n* '.join([s.root for s in self.failed_suites]) + '\n\n')
        else:
            msg = colorize('green', "\n\n{bar}\nNo test failures ".format(bar="=" * 48))

        print msg
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:11,代码来源:suite.py


示例9: report_test_results

    def report_test_results(self):
        """
        Writes a list of failed_suites to sys.stderr
        """
        if len(self.failed_suites) > 0:
            msg = colorize("red", "\n\n{bar}\nTests failed in the following suites:\n* ".format(bar="=" * 48))
            msg += colorize("red", "\n* ".join([s.root for s in self.failed_suites]) + "\n\n")
        else:
            msg = colorize("green", "\n\n{bar}\nNo test failures ".format(bar="=" * 48))

        print (msg)
开发者ID:sigberto,项目名称:edx-platform,代码行数:11,代码来源:suite.py


示例10: __init__

 def __init__(self, **options):
     Formatter.__init__(self, **options)
     self.compress = get_choice_opt(options, 'compress',
                                    ['', 'none', 'gz', 'bz2'], '')
     self.error_color = options.get('error_color', None)
     if self.error_color is True:
         self.error_color = 'red'
     if self.error_color is not None:
         try:
             colorize(self.error_color, '')
         except KeyError:
             raise ValueError("Invalid color %r specified" %
                              self.error_color)
开发者ID:mbialon,项目名称:yashapp,代码行数:13,代码来源:other.py


示例11: generate_optimized_static_assets

 def generate_optimized_static_assets(self, log_dir=None):
     """
     Collect static assets using test_static_optimized.py which generates
     optimized files to a dedicated test static root. Optionally use
     a log directory for collectstatic output.
     """
     print colorize('green', "Generating optimized static assets...")
     if not log_dir:
         sh("paver update_assets --settings=test_static_optimized")
     else:
         sh("paver update_assets --settings=test_static_optimized --collect-log={log_dir}".format(
             log_dir=log_dir
         ))
开发者ID:fangqian,项目名称:edx-platform,代码行数:13,代码来源:suite.py


示例12: __exit__

    def __exit__(self, exc_type, exc_value, traceback):
        super(BokChoyTestSuite, self).__exit__(exc_type, exc_value, traceback)

        # Using testsonly will leave all fixtures in place (Note: the db will also be dirtier.)
        if self.testsonly:
            msg = colorize('green', 'Running in testsonly mode... SKIPPING database cleanup.')
            print msg
        else:
            # Clean up data we created in the databases
            msg = colorize('green', "Cleaning up databases...")
            print msg
            sh("./manage.py lms --settings bok_choy flush --traceback --noinput")
            bokchoy_utils.clear_mongo()
开发者ID:AndreySonetico,项目名称:edx-platform,代码行数:13,代码来源:bokchoy_suite.py


示例13: __init__

 def __init__(self, **options):
     Formatter.__init__(self, **options)
     if self.encoding:
         raise OptionError("the raw formatter does not support the " "encoding option")
     self.encoding = "utf-8"  # let pygments.format() do the right thing
     self.compress = get_choice_opt(options, "compress", ["", "none", "gz", "bz2"], "")
     self.error_color = options.get("error_color", None)
     if self.error_color is True:
         self.error_color = "red"
     if self.error_color is not None:
         try:
             colorize(self.error_color, "")
         except KeyError:
             raise ValueError("Invalid color %r specified" % self.error_color)
开发者ID:robby31,项目名称:PythonQt,代码行数:14,代码来源:other.py


示例14: restart

    def restart(self):
        self.cls()
        print "%s" % console.reset_color()
        self.cls()

        op = raw_input(console.colorize('green', 'Timing again? ') +
                       console.colorize('turquoise', '(y/n)') +
                       console.colorize('green', ': '))
        if op in ("y", "Y"):
            self.clocking()
        elif op in ("n", "N"):
            print console.reset_color()
            self.cls()
            sys.exit(EXIT)
        else:
            self.restart()
开发者ID:FabianoZNC,项目名称:dotfiles,代码行数:16,代码来源:termtimer.py


示例15: generate_pr_table

def generate_pr_table(start_ref, end_ref):
    """
    Return a UTF-8 string corresponding to a pull request table to embed in Confluence.
    """
    header = "|| Merged By || Author || Title || PR || JIRA || Release Notes? || Verified? ||"
    pr_link = "[#{num}|https://github.com/edx/edx-platform/pull/{num}]"
    user_link = "[@{user}|https://github.com/{user}]"
    rows = [header]
    prbe = prs_by_email(start_ref, end_ref)
    for email, pull_requests in prbe.items():
        for i, pull_request in enumerate(pull_requests):
            try:
                pr_info = get_pr_info(pull_request)
                title = pr_info["title"] or ""
                body = pr_info["body"] or ""
                author = pr_info["user"]["login"]
            except requests.exceptions.RequestException as e:
                message = (
                    "Warning: could not fetch data for #{num}: "
                    "{message}".format(num=pull_request, message=e.message)
                )
                print(colorize("red", message), file=sys.stderr)
                title = "?"
                body = "?"
                author = ""
            rows.append("| {merged_by} | {author} | {title} | {pull_request} | {jira} | {release_notes} | {verified} |".format(
                merged_by=email if i == 0 else "",
                author=user_link.format(user=author) if author else "",
                title=title.replace("|", "\|").replace('{', '\{').replace('}', '\}'),
                pull_request=pr_link.format(num=pull_request),
                jira=", ".join(parse_ticket_references(body)),
                release_notes="",
                verified="",
            ))
    return "\n".join(rows).encode("utf8")
开发者ID:ammerender,项目名称:edx-platform,代码行数:35,代码来源:release.py


示例16: pretty_run

def pretty_run(to_run):
    if isinstance(to_run, basestring):
        text = to_run
    else:
        text = " ".join(to_run)
    sys.stderr.write(colorize("green", text + "\n"))
    return run(to_run)
开发者ID:rayleyva,项目名称:potamus,代码行数:7,代码来源:upload.py


示例17: __init__

 def __init__(self, **options):
     Formatter.__init__(self, **options)
     # We ignore self.encoding if it is set, since it gets set for lexer
     # and formatter if given with -Oencoding on the command line.
     self.encoding = 'ascii'  # let pygments.format() do the right thing
     self.compress = get_choice_opt(options, 'compress',
                                    ['', 'none', 'gz', 'bz2'], '')
     self.error_color = options.get('error_color', None)
     if self.error_color is True:
         self.error_color = 'red'
     if self.error_color is not None:
         try:
             colorize(self.error_color, '')
         except KeyError:
             raise ValueError("Invalid color %r specified" %
                              self.error_color)
开发者ID:bkerler,项目名称:PythonQt,代码行数:16,代码来源:other.py


示例18: section

 def section(self, message, opts={}):
     if 'plain' != self.settings['highlight']:
         message = colorize('bold', message)
     else:
         message += "\n" + '-' * len(message)
         pass
     self.msg(message)
开发者ID:gitter-badger,项目名称:python2-trepan,代码行数:7,代码来源:base_cmd.py


示例19: diff_coverage

def diff_coverage(options):
    """
    Build the diff coverage reports
    """
    compare_branch = getattr(options, "compare_branch", "origin/master")

    # Find all coverage XML files (both Python and JavaScript)
    xml_reports = []

    for filepath in Env.REPORT_DIR.walk():
        if filepath.basename() == "coverage.xml":
            xml_reports.append(filepath)

    if not xml_reports:
        err_msg = colorize("red", "No coverage info found.  Run `paver test` before running `paver coverage`.\n")
        sys.stderr.write(err_msg)
    else:
        xml_report_str = " ".join(xml_reports)
        diff_html_path = os.path.join(Env.REPORT_DIR, "diff_coverage_combined.html")

        # Generate the diff coverage reports (HTML and console)
        sh(
            "diff-cover {xml_report_str} --compare-branch={compare_branch} "
            "--html-report {diff_html_path}".format(
                xml_report_str=xml_report_str, compare_branch=compare_branch, diff_html_path=diff_html_path
            )
        )

        print("\n")
开发者ID:escolaglobal,项目名称:edx-platform,代码行数:29,代码来源:tests.py


示例20: coverage

def coverage():
    """
    Build the html, xml, and diff coverage reports
    """
    report_dir = Env.REPORT_DIR
    rcfile = Env.PYTHON_COVERAGERC

    if not (report_dir / '.coverage').isfile():
        # This may be that the coverage files were generated using -p,
        # try to combine them to the one file that we need.
        sh("coverage combine --rcfile={}".format(rcfile))

    if not os.path.getsize(report_dir / '.coverage') > 50:
        # Check if the .coverage data file is larger than the base file,
        # because coverage combine will always at least make the "empty" data
        # file even when there isn't any data to be combined.
        err_msg = colorize(
            'red',
            "No coverage info found.  Run `paver test` before running "
            "`paver coverage`.\n"
        )
        sys.stderr.write(err_msg)
        return

    # Generate the coverage.py XML report
    sh("coverage xml --rcfile={}".format(rcfile))
    # Generate the coverage.py HTML report
    sh("coverage html --rcfile={}".format(rcfile))
    diff_coverage()  # pylint: disable=no-value-for-parameter
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:29,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python filter.Filter类代码示例发布时间:2022-05-25
下一篇:
Python pygments.lex函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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