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


Python crayons.red方法代码示例

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


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

示例1: _cstate

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def _cstate(tw):
        """Returns state in colour for pretty printing reports."""
        if isinstance(tw, ThreadWrapper):
            if tw.state == ThreadState.SUCCESS:
                return str(crayons.green(tw.state.name))
            elif tw.state == ThreadState.FAILED:
                return str(crayons.red(tw.state.name))
            else:
                return str(crayons.yellow(tw.state.name))
        else:
            if ThreadState.SUCCESS.name in tw:
                return str(crayons.green(tw))
            elif ThreadState.FAILED.name in tw:
                return str(crayons.red(tw))
            else:
                return str(crayons.yellow(tw)) 
开发者ID:csurfer,项目名称:pypette,代码行数:18,代码来源:pipes.py

示例2: format_help

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def format_help(_help):
    """Formats the help string."""
    additional_help = """
    Examples:
        Get the circular imports in current project:
        $ {0}
        Look for circular imports in another project
        $ {1}
        Ignore specific directories when looking for circular import
        $ {2}
        Get verbose output
        $ {3}

Options:""".format(
        crayons.red('pycycle --here'),
        crayons.red('pycycle --source /home/user/workspace/awesome_project'),
        crayons.red('pycycle --source /home/user/workspace/awesome_project --ignore some_dir,some_dir2'),
        crayons.red('pycycle --source /home/user/workspace/awesome_project --verbose'),
    )

    _help = _help.replace('Options:', additional_help)

    return _help 
开发者ID:bndr,项目名称:pycycle,代码行数:25,代码来源:cli.py

示例3: linkfriendly

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def linkfriendly():
    global url
    global r
    global soup

    while True:
        #Gets user shopify link
        try:
            url = raw_input(crayons.cyan('PASTE LINK HERE: '))
            headers ={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36'
                    '(KHTML, like Gecko) Chrome/56.0.2924.28 Safari/537.36'}

            r = requests.get(url+'.xml' ,headers=headers )
            soup = BeautifulSoup(r.content, 'html.parser')
            break
            # Handles exceptions
        except (requests.exceptions.MissingSchema,requests.exceptions.InvalidURL,requests.exceptions.ConnectionError,
            requests.exceptions.InvalidSchema,NameError) as e:
            print crayons.red('link no bueno!')

#Grabs handle text 
开发者ID:ajnicolas,项目名称:Shopify-Stock-Checker,代码行数:23,代码来源:shopifychecker.py

示例4: start

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def start(self):
        print("")
        print("{} {}".format(crayons.yellow("Pulling image"),
                             crayons.red(self.image)))
        with blindspin.spinner():
            docker_client = self.get_docker_client()
            self._container = docker_client.run(self.image,
                                                command=self._command,
                                                detach=True,
                                                environment=self.env,
                                                ports=self.ports,
                                                name=self._name,
                                                volumes=self.volumes,
                                                **self._kargs
                                                )
        print("")
        print("Container started: ",
              crayons.yellow(self._container.short_id, bold=True))
        return self 
开发者ID:testcontainers,项目名称:testcontainers-python,代码行数:21,代码来源:container.py

示例5: report

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def report(self):
        """Method to pretty print the report."""
        print("")
        print(crayons.green(self.name, bold=True))

        if not self.thread_map:
            print(crayons.red("No jobs run in pipeline yet !"))
            return

        joblen = len(self.thread_map)
        for i, jobs in enumerate(self.thread_map.values()):
            print(crayons.blue(u"| "))
            if len(jobs) == 1:
                print(crayons.blue(u"\u21E8  ") + Pipe._cstate(jobs[0]))
            else:
                if i == joblen - 1:
                    pre = u"  "
                else:
                    pre = u"| "
                l1 = [u"-" * 10 for j in jobs]
                l1 = u"".join(l1)
                l1 = l1[:-1]
                print(crayons.blue(u"\u21E8 ") + crayons.blue(l1))
                fmt = u"{0:^{wid}}"
                l2 = [fmt.format(u"\u21E9", wid=12) for j in jobs]
                print(crayons.blue(pre) + crayons.blue(u"".join(l2)))
                l3 = [
                    Pipe._cstate(fmt.format(j.state.name, wid=12))
                    for j in jobs
                ]
                print(crayons.blue(pre) + u"".join(l3))

        pipes = filter(
            lambda x: isinstance(x.job, Pipe), chain(*self.thread_map.values())
        )

        for item in pipes:
            item.job.report() 
开发者ID:csurfer,项目名称:pypette,代码行数:40,代码来源:pipes.py

示例6: _pretty_print

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def _pretty_print(self):
        """Method to pretty print the pipeline."""
        print("")
        print(crayons.green(self.name, bold=True))

        if not self.job_map:
            print(crayons.red("No jobs added to the pipeline yet !"))
            return

        joblen = len(self.job_map)
        for i, jobs in enumerate(self.job_map.values()):
            print(crayons.blue(u"| "))
            if len(jobs) == 1:
                print(crayons.blue(u"\u21E8  ") + crayons.white(jobs[0].name))
            else:
                if i == joblen - 1:
                    pre = u"  "
                else:
                    pre = u"| "
                l1 = [u"-" * (len(j.name) + 2) for j in jobs]
                l1 = u"".join(l1)
                l1 = l1[: -len(jobs[-1].name) // 2 + 1]
                print(crayons.blue(u"\u21E8 ") + crayons.blue(l1))
                fmt = u"{0:^{wid}}"
                l2 = [fmt.format(u"\u21E9", wid=len(j.name) + 2) for j in jobs]
                print(crayons.blue(pre) + crayons.blue(u"".join(l2)))
                l3 = [fmt.format(j.name, wid=len(j.name) + 2) for j in jobs]
                print(crayons.blue(pre) + crayons.white(u"".join(l3)))

        pipes = filter(
            lambda x: isinstance(x, Pipe), chain(*self.job_map.values())
        )

        for item in pipes:
            item._pretty_print() 
开发者ID:csurfer,项目名称:pypette,代码行数:37,代码来源:pipes.py

示例7: collect_hashes

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def collect_hashes(self, ireq):
        from .vendor.requests import ConnectionError
        collected_hashes = []
        if ireq in self.hashes:
            collected_hashes += list(self.hashes.get(ireq, []))
        if self._should_include_hash(ireq):
            try:
                hash_map = self.get_hash(ireq)
                collected_hashes += list(hash_map)
            except (ValueError, KeyError, IndexError, ConnectionError):
                pass
        elif any(
            "python.org" in source["url"] or "pypi.org" in source["url"]
            for source in self.sources
        ):
            pkg_url = "https://pypi.org/pypi/{0}/json".format(ireq.name)
            session = _get_requests_session()
            try:
                # Grab the hashes from the new warehouse API.
                r = session.get(pkg_url, timeout=10)
                api_releases = r.json()["releases"]
                cleaned_releases = {}
                for api_version, api_info in api_releases.items():
                    api_version = clean_pkg_version(api_version)
                    cleaned_releases[api_version] = api_info
                version = ""
                if ireq.specifier:
                    spec = next(iter(s for s in list(ireq.specifier._specs)), None)
                    if spec:
                        version = spec.version
                for release in cleaned_releases[version]:
                    collected_hashes.append(release["digests"]["sha256"])
                collected_hashes = self.prepend_hash_types(collected_hashes)
            except (ValueError, KeyError, ConnectionError):
                if environments.is_verbose():
                    click_echo(
                        "{0}: Error generating hash for {1}".format(
                            crayons.red("Warning", bold=True), ireq.name
                        ), err=True
                    )
        return collected_hashes 
开发者ID:pypa,项目名称:pipenv,代码行数:43,代码来源:utils.py

示例8: cli

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def cli(ctx, verbose=False, help=False, source=None, here=False, ignore='', encoding=None):
    if ctx.invoked_subcommand is None:

        if source:
            source = os.path.abspath(source)
            click.echo(crayons.yellow(
                'Target source provided: {}'.format(source)))
        elif here:
            source = os.getcwd()
        else:
            # Display help to user, if no commands were passed.
            click.echo(format_help(ctx.get_help()))
            sys.exit(0)

        if not source:
            click.echo(crayons.red(
                'No project provided. Provide either --here or --source.'))

        if not os.path.isdir(source):
            click.echo(crayons.red('Directory does not exist.'), err=True)
            sys.exit(1)

        root_node = read_project(source, verbose=verbose, ignore=ignore.split(','), encoding=encoding)

        click.echo(crayons.yellow(
            'Project successfully transformed to AST, checking imports for cycles..'))

        if check_if_cycles_exist(root_node):
            click.echo(crayons.red('Cycle Found :('))
            click.echo(crayons.red(get_cycle_path(root_node)))
            click.echo(crayons.green("Finished."))
            sys.exit(1)
        else:
            click.echo(crayons.green(('No worries, no cycles here!')))
            click.echo(crayons.green(
                'If you think some cycle was missed, please open an Issue on Github.'))
            click.echo(crayons.green("Finished."))
            sys.exit(0) 
开发者ID:bndr,项目名称:pycycle,代码行数:40,代码来源:cli.py

示例9: colordiff

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def colordiff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'):
    for i, diff in enumerate(unified_diff(a, b, fromfile, tofile, fromfiledate, tofiledate, n, lineterm)):
        if i < 2:
            yield str(crayons.white(diff, bold=True))
        elif diff.startswith("@"):
            yield str(crayons.blue(diff))
        elif diff.startswith("+"):
            yield str(crayons.green(diff))
        elif diff.startswith("-"):
            yield str(crayons.red(diff))
        else:
            yield diff 
开发者ID:jaksi,项目名称:awslog,代码行数:14,代码来源:__init__.py

示例10: grabszstk

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def grabszstk():
    sz = []
    for size in soup.findAll("title")[1:]:
        # find text then append to a list
        sz.append(size)
 
    stk = []
    for stock in soup.findAll("inventory-quantity"):
        stk.append(stock)

    variants = []
    for variant in soup.findAll("id")[1:]:
        variants.append(variant)
    #Gets the total
    total = []
    for stock in soup.findAll("inventory-quantity"):
        total.append(int(stock.text))
    
    # formats the data
    fmt = '{:<5}{:<13}{:<10}{}'
    fmat = '{:<5}{:<13}{}'

    # zips the for lists together
    if len(stk) > 0:
        print(fmt.format('', 'size', 'stock', 'variant'))
        for i, (sz, stk, variants) in enumerate(zip(sz, stk, variants)):
            print(fmt.format(i, sz.text, stk.text, variants.text))
        print 'TOTAL STOCK:', sum(total)

    #if stock wasn't found
    else:
        print crayons.red('STOCK WAS NOT FOUND')
        print(fmat.format('', 'size','variant'))
        for i, (sz,variants) in enumerate(zip(sz,variants)):
            print(fmat.format(i, sz.text, variants.text))

#Also bad formatting 
开发者ID:ajnicolas,项目名称:Shopify-Stock-Checker,代码行数:39,代码来源:shopifychecker.py

示例11: formattext

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def formattext():
    print '--' * 38
    print crayons.blue(url)
    print crayons.yellow('Press cmd + double click link to go to link!')
    try:
        print grabhandle() + ' | ' + grabdate() + ' \n' + crayons.green(grabprice()) + ' \n' + grabsku()
        print ' '*38
        grabszstk()
        print crayons.yellow('Press ctrl + z to exit')
    except TypeError:
        print crayons.red("Try copying everything before the '?variant' \n or before the '?' in the link!".upper())

#While true statment for multiple link checks! 
开发者ID:ajnicolas,项目名称:Shopify-Stock-Checker,代码行数:15,代码来源:shopifychecker.py

示例12: resolve

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def resolve(cmd, sp):
    import delegator
    from .cmdparse import Script
    from .vendor.pexpect.exceptions import EOF, TIMEOUT
    from .vendor.vistir.compat import to_native_string
    from .vendor.vistir.misc import echo
    EOF.__module__ = "pexpect.exceptions"
    from ._compat import decode_output
    c = delegator.run(Script.parse(cmd).cmdify(), block=False, env=os.environ.copy())
    if environments.is_verbose():
        c.subprocess.logfile = sys.stderr
    _out = decode_output("")
    result = None
    out = to_native_string("")
    while True:
        result = None
        try:
            result = c.expect(u"\n", timeout=environments.PIPENV_INSTALL_TIMEOUT)
        except TIMEOUT:
            pass
        except EOF:
            break
        except KeyboardInterrupt:
            c.kill()
            break
        if result:
            _out = c.subprocess.before
            _out = decode_output("{0}".format(_out))
            out += _out
            # sp.text = to_native_string("{0}".format(_out[:100]))
            if environments.is_verbose():
                sp.hide_and_write(out.splitlines()[-1].rstrip())
        else:
            break
    c.block()
    if c.return_code != 0:
        sp.red.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(
            "Locking Failed!"
        ))
        echo(c.out.strip(), err=True)
        if not environments.is_verbose():
            echo(out, err=True)
        sys.exit(c.return_code)
    if environments.is_verbose():
        echo(c.err.strip(), err=True)
    return c 
开发者ID:pypa,项目名称:pipenv,代码行数:48,代码来源:utils.py

示例13: enqueue

# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import red [as 别名]
def enqueue(self, file, forced_profile: Optional[str]) -> (str, Optional[EncodeJob]):
        """Add a media file to this cluster queue.
           This is different than in local mode in that we only care about handling skips here.
           The profile will be selected once a host is assigned to the work
        """

        path = os.path.abspath(file)  # convert to full path so that rule filtering can work
        if pytranscoder.verbose:
            print('matching ' + path)

        media_info = self.ffmpeg.fetch_details(path)
        if media_info is None:
            print(crayons.red(f'File not found: {path}'))
            return None, None
        if media_info.valid:

            if pytranscoder.verbose:
                print(str(media_info))

            if forced_profile is None:
                #
                # just interested in SKIP rule matches and queue designations here
                #

                profile = None
                rule = self.config.match_rule(media_info)
                if rule is None:
                    print(crayons.yellow(f'No matching profile found - skipped'))
                    return None, None
                if rule.is_skip():
                    basename = os.path.basename(path)
                    print(f'{basename}: Skipping due to profile rule - {rule.name}')
                    return None, None
                profile = self.profiles[rule.profile]
            else:
                profile = self.profiles[forced_profile]

            if pytranscoder.verbose:
                print("Matched to profile {profile.name}")

            # not short circuited by a skip rule, add to appropriate queue
            queue_name = profile.queue_name if profile.queue_name is not None else '_default'
            if queue_name not in self.queues:
                print(crayons.red('Error: ') +
                      f'Queue "{queue_name}" referenced in profile "{profile.name}" not defined in any host')
                exit(1)
            job = EncodeJob(file, media_info, profile.name)
            self.queues[queue_name].put(job)
            return queue_name, job
        return None, None 
开发者ID:mlsmithjr,项目名称:transcoder,代码行数:52,代码来源:cluster.py


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