python类RESET_ALL的实例源码

gtpp.py 文件源码 项目:gtpp 作者: joshkel 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def print_status(self, test_case, test_case_index, total_test_case_count, character,
                     color=None, details=None, force_progress=False, progress_space=' '):
        """Implementation: Prints a line of test / test case progress."""
        if test_case_index is None:
            line = progress_space * self.progress_len
        elif self.printer.needs_newline or force_progress:
            line = self.progress(test_case_index, total_test_case_count)
            self.progress_len = len(line)
        else:
            line = self.space_for_progress(test_case_index, total_test_case_count)
            self.progress_len = len(line)

        if color:
            line += color
        line += ' ' + character + ' ' + test_case
        if color:
            line += Style.RESET_ALL
        if details:
            line += details

        self.printer.print_noeol(line)
gtpp.py 文件源码 项目:gtpp 作者: joshkel 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def finish(self, total_test_count, total_test_case_count, time):
        time_details = self.format_time(time)
        if not self.failed_test_output:
            passed_details = ' - ' + self.format_passed(total_test_count, total_test_case_count)
            self.print_status('Finished', None, None, self.characters.success, Fore.GREEN,
                              details=passed_details + time_details, progress_space='-')
        else:
            failed_details = ' - ' + self.format_failed(
                len(self.failed_test_output), total_test_count, total_test_case_count)
            self.print_status('Finished', None, None, self.characters.fail, Fore.RED,
                              details=failed_details + time_details, progress_space='-')
        self.printer.newline()

        if self.failed_test_output:
            self.printer.print()
            self.printer.print(Fore.RED + 'FAILED TESTS:' + Style.RESET_ALL)
            for test_and_case, output in self.failed_test_output.items():
                self.printer.print(
                    Fore.RED + self.characters.fail + ' ' + test_and_case + Style.RESET_ALL)
                for line in output:
                    self.printer.print('    ' + line)
gtpp.py 文件源码 项目:gtpp 作者: joshkel 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def print_exit_status(process, printer):
    exit_signal = None
    exit_code = None
    core_dumped = False

    try:
        wait_result = os.waitpid(process.pid, 0)[1]
        if os.WIFSIGNALED(wait_result):
            exit_signal = os.WTERMSIG(wait_result)
            exit_code = 128 + exit_signal
        elif os.WIFEXITED(wait_result):
            exit_code = os.WEXITSTATUS(wait_result)
        core_dumped = os.WCOREDUMP(wait_result)
    except ChildProcessError:
        # Must be Windows; waiting for a terminated process doesn't work (?)
        exit_code = process.returncode

    if exit_signal is not None:
        signal_name = signal_names.get(exit_signal, 'unknown signal')
        printer.print(
            Fore.RED + 'Terminated by %s (%i)' % (signal_name, exit_signal) + Style.RESET_ALL)
        exit_code = 128 + exit_signal
    if core_dumped:
        printer.print(Fore.RED + 'Core dumped' + Style.RESET_ALL)
    return exit_code
stitch_utils.py 文件源码 项目:Stitch 作者: nathanlopez 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def print_yellow(string):
    if windows_client(): reinit()
    print (Fore.YELLOW + Style.BRIGHT + string + Style.RESET_ALL)
    if windows_client(): deinit()
stitch_utils.py 文件源码 项目:Stitch 作者: nathanlopez 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def print_blue(string):
    if windows_client(): reinit()
    print (Fore.BLUE + Style.BRIGHT + string + Style.RESET_ALL)
    if windows_client(): deinit()
stitch_utils.py 文件源码 项目:Stitch 作者: nathanlopez 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def print_cyan(string):
    if windows_client(): reinit()
    print (Fore.CYAN + Style.BRIGHT + string + Style.RESET_ALL)
    if windows_client(): deinit()
stitch_utils.py 文件源码 项目:Stitch 作者: nathanlopez 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def print_green(string):
    if windows_client(): reinit()
    print (Fore.GREEN + Style.BRIGHT + string + Style.RESET_ALL)
    if windows_client(): deinit()
stitch_utils.py 文件源码 项目:Stitch 作者: nathanlopez 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def print_red(string):
    if windows_client(): reinit()
    print (Fore.RED + Style.BRIGHT + string + Style.RESET_ALL)
    if windows_client(): deinit()
logging.py 文件源码 项目:engel 作者: Dalloriam 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def info(message):
    print(Style.RESET_ALL + message)
logging.py 文件源码 项目:engel 作者: Dalloriam 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def reset():
    print(Style.RESET_ALL)
main.py 文件源码 项目:skymod 作者: DelusionalLogic 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def set_(name, value):
    section, option = name.split(".")
    try:
        cfg[section][option] = value
    except KeyError:
        print(
            "Unknown config option {Style.BRIGHT}{}{Style.RESET_ALL}"
            .format(
                name,
                Style=Style
            )
        )
main.py 文件源码 项目:skymod 作者: DelusionalLogic 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get(name):
    section, option = name.split(".")
    try:
        print(cfg[section][option])
    except KeyError:
        print(
            "Unknown config option {Style.BRIGHT}{}{Style.RESET_ALL}"
            .format(
                name,
                Style=Style
            )
        )
main.py 文件源码 项目:skymod 作者: DelusionalLogic 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def details(package_q):
    q = Query(package_q)
    package = local_repo.find_package(q)
    if package is None:
        print("No package named {Style.BRIGHT}{}{Style.RESET_ALL}".format(
            q,
            Style=Style
        ))
        exit(1)
    print_local_package(local_repo, package)
packagelist.py 文件源码 项目:skymod 作者: DelusionalLogic 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def present(self):
        for package in self.list_:
            tag_str = " ".join(
                ("{}[{}]".format(k.color, k) for k in self.tags[package])
            )
            print("{}/{} {}".format(
                Fore.MAGENTA + package.name + Style.RESET_ALL,
                package.version,
                tag_str
                ))
common_funs.py 文件源码 项目:identifiera-sarkasm 作者: risnejunior 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _compile_table(self, name):
        # for readability
        metrics = self.metrics[name]
        fn = metrics['fn']; fp = metrics['fp']; tp = metrics['tp']; tn = metrics['tn']

        pt = PrettyTable([Fore.GREEN + name + Style.RESET_ALL,'Predicted NO','Predicted YES','Total'])
        pt.add_row(['Actual NO',tn,fp,tn+fp])
        pt.add_row(['Actual YES',fn,tp,fn+tp])
        pt.add_row(['Total',tn+fn,fp+tp,''])
        pt.hrules = ALL

        rows = ['' for i in range(6)]
        rows[0] = pt.get_string(padding_width=5)
        rows[1] = "Accuracy: {:^1}{:<.2f}".format("", metrics['accuracy'])
        rows[2] = "Precision: {:^}{:<.2f}".format("", metrics['precision'])
        rows[3] = "Recall: {:^3}{:<.2f}".format("",   metrics['recall'])
        rows[4] = "F1-score: {:^1}{:<.2f}".format("", metrics['f1_score'])
        rows[5] = ""

        self.rows.extend(rows)
binarly_query.py 文件源码 项目:binarly-query 作者: binarlyhq 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def color_row(row):
    color = Fore.WHITE
    label = "."
    if u'label' in row:
        color = LABEL_COLOR.get(row[u'label'], Fore.WHITE)
        label = row[u'label']
        row[u'label'] = "%s%s%s" % (color, label, Style.RESET_ALL)

    row['family'] = "%s%s%s" % (color, row.get('family', "."), Style.RESET_ALL)
    row['size'] = smart_size(row.get(u'size', "."))
    return row
binarly_query.py 文件源码 项目:binarly-query 作者: binarlyhq 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def process_classify(options):
    if os.path.exists(options.files[0]):
        filelist = options.files
        if os.path.isdir(options.files[0]):
            filelist = get_filelist(filelist[0])

        result = BINOBJ.classify_files(
            filelist, upload_missing=options.u, status_callback=my_callback)
    else:
        result = BINOBJ.classify_hashes(options.files)

    if 'error' in result or result['status'] != 'done':
        print(Style.BRIGHT + Fore.RED + "Request failed")
    else:
        print("Classification Results:")

    reqid = result.get('results', None)
    if reqid is None:
        # the request failed before any files could be analyzed
        print(Style.BRIGHT + Fore.RED +
              "Fail reason: {0} (error code={1})".format(
                  result['error']['message'], result['error']['code']))
        return

    classify_data = []
    for key, value in result['results'].iteritems():
        status = Style.RESET_ALL + Fore.GREEN + "OK" + Style.RESET_ALL
        if 'error' in value:
            status = Fore.RED + value['error']['message'] + Style.RESET_ALL
        row = {'SHA1': key, 'label': value.get('label', '.'), 'family': value.get('family', '.'), 'Status': status}

        classify_data.append(row)

    if options.pretty_print:
        show_results(classify_data, pretty_print=options.pretty_print)
    else:
        print("-" * 100)
        for row in classify_data:
            show_row(row)
    return
markup.py 文件源码 项目:python-ansimarkup 作者: gvalkov 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def parse(self, text):
        '''Return a string with markup tags converted to ansi-escape sequences.'''
        tags, results = [], []

        text = self.re_tag.sub(lambda m: self.sub_tag(m, tags, results), text)

        if self.always_reset:
            if not text.endswith(Style.RESET_ALL):
                text += Style.RESET_ALL

        return text
test_markup.py 文件源码 项目:python-ansimarkup 作者: gvalkov 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_flat():
    assert p('<b>1</b>') == p('<bold>1</bold>') == S.BRIGHT + '1' + S.RESET_ALL
    assert p('<d>1</d>') == p('<dim>1</dim>')   == S.DIM    + '1' + S.RESET_ALL

    assert p('<b>1</b><d>2</d>')  == S.BRIGHT + '1' + S.RESET_ALL    +    S.DIM + '2' + S.RESET_ALL
    assert p('<b>1</b>2<d>3</d>') == S.BRIGHT + '1' + S.RESET_ALL + '2' + S.DIM + '3' + S.RESET_ALL


问题


面经


文章

微信
公众号

扫码关注公众号