当前位置: 首页>>代码示例>>Python>>正文


Python Back.RESET属性代码示例

本文整理汇总了Python中colorama.Back.RESET属性的典型用法代码示例。如果您正苦于以下问题:Python Back.RESET属性的具体用法?Python Back.RESET怎么用?Python Back.RESET使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在colorama.Back的用法示例。


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

示例1: red

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def red(s: str) -> str:  # pragma: no cover
    """Red color string if tty
    
    Args:
        s (str): String to color
    
    Returns:
        str: Colored string

    Examples:
        >>> from chepy.modules.internal.colors import red
        >>> print(RED("some string"))
    """
    if sys.stdout.isatty():
        return Fore.RED + s + Fore.RESET
    else:
        return s 
开发者ID:securisec,项目名称:chepy,代码行数:19,代码来源:colors.py

示例2: blue

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def blue(s: str) -> str:  # pragma: no cover
    """Blue color string if tty
    
    Args:
        s (str): String to color
    
    Returns:
        str: Colored string

    Examples:
        >>> from chepy.modules.internal.colors import blue
        >>> print(BLUE("some string"))
    """
    if sys.stdout.isatty():
        return Fore.BLUE + s + Fore.RESET
    else:
        return s 
开发者ID:securisec,项目名称:chepy,代码行数:19,代码来源:colors.py

示例3: cyan

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def cyan(s: str) -> str:  # pragma: no cover
    """Cyan color string if tty
    
    Args:
        s (str): String to color
    
    Returns:
        str: Colored string

    Examples:
        >>> from chepy.modules.internal.colors import cyan
        >>> print(CYAN("some string"))
    """
    if sys.stdout.isatty():
        return Fore.CYAN + s + Fore.RESET
    else:
        return s 
开发者ID:securisec,项目名称:chepy,代码行数:19,代码来源:colors.py

示例4: green

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def green(s: str) -> str:  # pragma: no cover
    """Green color string if tty
    
    Args:
        s (str): String to color
    
    Returns:
        str: Colored string

    Examples:
        >>> from chepy.modules.internal.colors import green
        >>> print(GREEN("some string"))
    """
    if sys.stdout.isatty():
        return Fore.GREEN + s + Fore.RESET
    else:
        return s 
开发者ID:securisec,项目名称:chepy,代码行数:19,代码来源:colors.py

示例5: magenta

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def magenta(s: str) -> str:  # pragma: no cover
    """Magenta color string if tty
    
    Args:
        s (str): String to color
    
    Returns:
        str: Colored string

    Examples:
        >>> from chepy.modules.internal.colors import magenta
        >>> print(MAGENTA("some string"))
    """
    if sys.stdout.isatty():
        return Fore.MAGENTA + s + Fore.RESET
    else:
        return s 
开发者ID:securisec,项目名称:chepy,代码行数:19,代码来源:colors.py

示例6: _wrap_color

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def _wrap_color(code_string):
    """Wrap key parts in styling and resets.
    Stying for each key part from, 
    (col_offset, fromlineno) to (end_col_offset, end_lineno).
    Note: use this to set color back to default (on mac, and others?): 
          Style.RESET_ALL + Style.DIM
    """
    ret = Style.BRIGHT + Fore.WHITE + Back.BLACK
    ret += code_string
    ret += Style.RESET_ALL + Style.DIM + Fore.RESET + Back.RESET
    return ret 
开发者ID:pyta-uoft,项目名称:pyta,代码行数:13,代码来源:print_nodes.py

示例7: execute_command

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def execute_command(self):
        """
        The web command runs the Scrapple web interface through a simple \
        `Flask <http://flask.pocoo.org>`_ app. 

        When the execute_command() method is called from the \
        :ref:`runCLI() <implementation-cli>` function, it starts of two simultaneous \
        processes : 

        - Calls the run_flask() method to start the Flask app on port 5000 of localhost
        - Opens the web interface on a web browser

        The '/' view of the Flask app, opens up the Scrapple web interface. This \
        provides a basic form, to fill in the required configuration file. On submitting \
        the form, it makes a POST request, passing in the form in the request header. \
        This form is passed to the form_to_json() \
        :ref:`utility function <implementation-utils>`, where the form is converted into \
        the resultant JSON configuration file.

        Currently, closing the web command execution requires making a keyboard interrupt \
        on the command line after the web interface has been closed.

        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Web Interface")
        print(Back.RESET + Fore.RESET)
        p1 = Process(target = self.run_flask)
        p2 = Process(target = lambda : webbrowser.open('http://127.0.0.1:5000'))
        p1.start()
        p2.start() 
开发者ID:AlexMathew,项目名称:scrapple,代码行数:31,代码来源:web.py

示例8: execute_command

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def execute_command(self):
        """
        The generate command uses `Jinja2 <http://jinja.pocoo.org/>`_ templates \
        to create Python scripts, according to the specification in the configuration \
        file. The predefined templates use the extract_content() method of the \
        :ref:`selector classes <implementation-selectors>` to implement linear extractors \
        and use recursive for loops to implement multiple levels of link crawlers. This \
        implementation is effectively a representation of the traverse_next() \
        :ref:`utility function <implementation-utils>`, using the loop depth to \
        differentiate between levels of the crawler execution. 

        According to the --output_type argument in the CLI input, the results are \
        written into a JSON document or a CSV document. 

        The Python script is written into <output_filename>.py - running this file \
        is the equivalent of using the Scrapple :ref:`run command <command-run>`. 

        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Generate")
        print(Back.RESET + Fore.RESET)
        directory = os.path.join(scrapple.__path__[0], 'templates', 'scripts')
        with open(os.path.join(directory, 'generate.txt'), 'r') as f:
            template_content = f.read()
        template = Template(template_content)
        try:
            with open(self.args['<projectname>'] + '.json', 'r') as f:
                config = json.load(f)
            if self.args['--output_type'] == 'csv':
                from scrapple.utils.config import extract_fieldnames
                config['fields'] = str(extract_fieldnames(config))
            config['output_file'] = self.args['<output_filename>']
            config['output_type'] = self.args['--output_type']
            rendered = template.render(config=config)
            with open(self.args['<output_filename>'] + '.py', 'w') as f:
                f.write(rendered)
            print(Back.WHITE + Fore.RED + self.args['<output_filename>'], \
                  ".py has been created" + Back.RESET + Fore.RESET, sep="")
        except IOError:
            print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json does not ", \
                  "exist. Use ``scrapple genconfig``." + Back.RESET + Fore.RESET, sep="") 
开发者ID:AlexMathew,项目名称:scrapple,代码行数:42,代码来源:generate.py

示例9: execute_command

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def execute_command(self):
        """
        The genconfig command depends on predefined `Jinja2 <http://jinja.pocoo.org/>`_ \
        templates for the skeleton configuration files. Taking the --type argument from the \
        CLI input, the corresponding template file is used. 

        Settings for the configuration file, like project name, selector type and URL \
        are taken from the CLI input and using these as parameters, the template is \
        rendered. This rendered JSON document is saved as <project_name>.json.
        
        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Genconfig")
        print(Back.RESET + Fore.RESET)
        directory = os.path.join(scrapple.__path__[0], 'templates', 'configs')
        with open(os.path.join(directory, self.args['--type'] + '.txt'), 'r') as f:
            template_content = f.read()
        print("\n\nUsing the", self.args['--type'], "template\n\n")
        template = Template(template_content)
        settings = {
            'projectname': self.args['<projectname>'],
            'selector_type': self.args['--selector'],
            'url': self.args['<url>'],
            'levels': int(self.args['--levels'])
        }
        rendered = template.render(settings=settings)
        with open(self.args['<projectname>'] + '.json', 'w') as f:
            rendered_data = json.loads(rendered)
            json.dump(rendered_data, f, indent=3)
        print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json has been created" \
            + Back.RESET + Fore.RESET, sep="") 
开发者ID:AlexMathew,项目名称:scrapple,代码行数:32,代码来源:genconfig.py

示例10: traverse_next

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def traverse_next(page, nextx, results, tabular_data_headers=[], verbosity=0):
    """
    Recursive generator to traverse through the next attribute and \
    crawl through the links to be followed.

    :param page: The current page being parsed
    :param next: The next attribute of the current scraping dict
    :param results: The current extracted content, stored in a dict
    :return: The extracted content, through a generator

    """
    for link in page.extract_links(selector=nextx['follow_link']):
        if verbosity > 0:
            print('\n')
            print(Back.YELLOW + Fore.BLUE + "Loading page ", link.url + Back.RESET + Fore.RESET, end='')
        r = results.copy()
        for attribute in nextx['scraping'].get('data'):
            if attribute['field'] != "":
                if verbosity > 1:
                    print("\nExtracting", attribute['field'], "attribute", sep=' ', end='')
                r[attribute['field']] = link.extract_content(**attribute)
        if not nextx['scraping'].get('table'):
            result_list = [r]
        else:
            tables = nextx['scraping'].get('table', [])
            for table in tables:
                table.update({
                    'result': r,
                    'verbosity': verbosity
                })
                table_headers, result_list = link.extract_tabular(**table)
                tabular_data_headers.extend(table_headers)
        if not nextx['scraping'].get('next'):
            for r in result_list:
                yield (tabular_data_headers, r)
        else:
            for nextx2 in nextx['scraping'].get('next'):
                for tdh, result in traverse_next(link, nextx2, r, tabular_data_headers=tabular_data_headers, verbosity=verbosity):
                    yield (tdh, result) 
开发者ID:AlexMathew,项目名称:scrapple,代码行数:41,代码来源:config.py

示例11: yellow_background

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def yellow_background(s: str) -> str:  # pragma: no cover
    """Yellow color string if tty
    
    Args:
        s (str): String to color
    
    Returns:
        str: Colored string
    """
    if sys.stdout.isatty():
        return Back.YELLOW + Fore.BLACK + s + Fore.RESET + Back.RESET
    else:
        return s 
开发者ID:securisec,项目名称:chepy,代码行数:15,代码来源:colors.py

示例12: _print

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def _print(self, text='', fore_color=Fore.WHITE, end=' '):
        if self.enable_color:
            print(fore_color + text, end='')
            print(Fore.RESET + Back.RESET + Style.RESET_ALL, end=end)
        else:
            print(text, end=end) 
开发者ID:wolfg1969,项目名称:oh-my-stars,代码行数:8,代码来源:view.py

示例13: _highlight_keywords

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def _highlight_keywords(self, text, keywords, fore_color=Fore.GREEN):
        if keywords and self.enable_color:
            for keyword in keywords:
                regex = re.compile(keyword, re.I | re.U | re.M)
                color = fore_color + Back.RED + Style.BRIGHT
                text = regex.sub(
                    color + keyword + Back.RESET + Style.NORMAL, text)
        return text 
开发者ID:wolfg1969,项目名称:oh-my-stars,代码行数:10,代码来源:view.py

示例14: show

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def show(args):
    """Print out the contents of an entry to console"""

    kp = open_database(**vars(args))

    entry = get_entry(kp, args.path)
    # show specified field
    if args.field:
        # handle lowercase field input gracefully
        field = get_field(entry, args.field)
        print(entry._get_string_field(field), end='')

    # otherwise, show all fields
    else:
        print(green("Title: ") + (entry.title or ''))
        print(green("UserName: ") + (entry.username or ''))
        print(
            green("Password: ") + Fore.RED + Back.RED +
            (entry.password or '') +
            Fore.RESET + Back.RESET
        )
        print(green("URL: ") + (entry.url or ''))
        for field_name, field_value in entry.custom_properties.items():
            print(green("{}: ".format(field_name)) + str(field_value or ''))
        print(green("Created: ") + entry.ctime.isoformat())
        print(green("Modified: ") + entry.mtime.isoformat()) 
开发者ID:Evidlo,项目名称:passhole,代码行数:28,代码来源:passhole.py

示例15: disp_err_corr

# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import RESET [as 别名]
def disp_err_corr(hyp_corr, ref_corr):
    hyp_str = ''
    ref_str = ''
    assert len(hyp_corr) == len(ref_corr)
    for k in xrange(len(hyp_corr)):
        if hyp_corr[k] == '[space]':
            hc = ' '
        elif hyp_corr[k] == '<ins>':
            hc = Back.GREEN + ' ' + Back.RESET
        else:
            hc = hyp_corr[k]

        if ref_corr[k] == '[space]':
            rc = ' '
        elif ref_corr[k] == '<del>':
            rc = Back.RED + ' ' + Back.RESET
        else:
            rc = ref_corr[k]

        if hc != rc and len(hc) == 1 and len(rc) == 1:
            hc = Back.BLUE + Fore.BLACK + hc + Fore.RESET + Back.RESET
            rc = Back.BLUE + Fore.BLACK + rc + Fore.RESET + Back.RESET
        hyp_str += hc
        ref_str += rc
    print hyp_str
    print ref_str 
开发者ID:amaas,项目名称:stanford-ctc,代码行数:28,代码来源:errorAnalysis.py


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