Python click 模块,pause() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用click.pause()

项目:two1-python    作者:21dotco    | 项目源码 | 文件源码
def get_or_create_wallet(wallet_path):
    """Create a new wallet or return the currently existing one."""
    data_provider = twentyone_provider.TwentyOneProvider(two1.TWO1_PROVIDER_HOST)

    if wallet.Two1Wallet.check_wallet_file(wallet_path):
        return wallet.Wallet(wallet_path=wallet_path, data_provider=data_provider)

    # configure wallet with default options
    click.pause(uxstring.UxString.create_wallet)

    wallet_options = dict(data_provider=data_provider, wallet_path=wallet_path)

    if not wallet.Two1Wallet.configure(wallet_options):
        raise click.ClickException(uxstring.UxString.Error.create_wallet_failed)

    # Display the wallet mnemonic and tell user to back it up.
    # Read the wallet JSON file and extract it.
    with open(wallet_path, 'r') as f:
        wallet_config = json.load(f)
        mnemonic = wallet_config['master_seed']

    click.pause(uxstring.UxString.create_wallet_done % click.style(mnemonic, fg='green'))

    if wallet.Two1Wallet.check_wallet_file(wallet_path):
        return wallet.Wallet(wallet_path=wallet_path, data_provider=data_provider)
项目:ovh-cli    作者:ovh    | 项目源码 | 文件源码
def launch_setup_2(ctx):
    """Choice 1 : user has the AK and AS tokens. We generate for him a link to
    validate the CK token."""
    endpoint = click.prompt('Endpoint', default='ovh-eu',
                            value_proc=check_endpoint)
    application_key = click.prompt('Application key')
    application_secret = click.prompt('Application secret')

    ctx.echo('')
    validation = get_ck_validation(endpoint, application_key,
                                   application_secret)
    ctx.info("Please visit the following link to authenticate you and "
             "validate the token :")
    ctx.info(validation['validationUrl'])
    click.pause()

    create_config_file(endpoint, application_key,
                       application_secret, validation['consumerKey'])

    ctx.success('Configuration file created.')
项目:instawow    作者:layday    | 项目源码 | 文件源码
def install():
    """Install the instawow BitBar plug-in."""
    from pathlib import Path
    import tempfile
    import sys

    with tempfile.TemporaryDirectory() as name:
        path = Path(name, 'instawow.1h.py')
        path.write_text(f'''\
#!/usr/bin/env LC_ALL=en_US.UTF-8 {sys.executable}

__version__ = {__version__!r}

import sys

from instawow.cli import main

main(['-n', *(sys.argv[1:] or ['extras', 'bitbar', '_generate', sys.argv[0], __version__])])
''')
        webbrowser.open(f'bitbar://openPlugin?src={path.as_uri()}')
        click.pause('Press any key to exit after installing the plug-in')
项目:flashcards    作者:zergov    | 项目源码 | 文件源码
def show_question(self, question):
        """
        Display the current question to the user.

        :param question: the question to display
        """
        header = '[QUESTION %s / %s]' % (self.question_count, self.question_num)
        click.echo(header)
        click.echo('\n' + question + '\n')
        click.pause('...')
项目:flashcards    作者:zergov    | 项目源码 | 文件源码
def show_answer(self, answer):
        """
        Display the answer to the question.

        :param answer: the answer
        """
        self.question_count += 1
        click.echo('\n' + answer + '\n')
        click.pause('Press any key to show next question')
项目:two1-python    作者:21dotco    | 项目源码 | 文件源码
def show_minertop(show_dashboard):
    """ Start minertop, the mining dashboard.

    Args:
        show_dashboard (bool): shows the dashboard if True
    """
    if show_dashboard:
        click.pause(uxstring.UxString.mining_show_dashboard_prompt)
        subprocess.call("minertop", shell=True)
    else:
        logger.info(uxstring.UxString.mining_show_dashboard_context)
项目:ovh-cli    作者:ovh    | 项目源码 | 文件源码
def launch_setup_3(ctx):
    """Choice 3 : the user does not have key, we provide him a link to
    generate it."""
    ctx.info("Please visit the following link to authenticate you and "
             "obtain your keys (AK, AS and CK) :")
    ctx.info(CREATE_TOKEN_LINK)
    click.pause()
    ctx.echo('')

    launch_setup_1(ctx)
项目:jira_pub_sync    作者:d-lobanov    | 项目源码 | 文件源码
def edit_unsync_issues(cls, issues):
        """
        Allows a user to manage all new tasks. They can have three statuses: migrate, skip and hide.
        """

        MARKER = """
# Commands:
# m = migrate issue.
# s = skip issue for this time (also you can just remove the line).
# h = hide issue (skip and never migrate).
        """

        max_len = max([len(issue.fields.summary) for issue in issues])
        max_len = max_len if max_len < 200 else 200

        def line_format(issue):
            summary = cls.truncate_summary(issue.fields.summary, max_len).ljust(max_len + 2)

            return 'm  ' + issue.key + '\t' + summary + '  ' + issue.permalink()

        items = [line_format(issue) for issue in issues]

        while True:
            message = click.edit("\n".join(items) + '\n\n' + MARKER)
            if message is None:
                raise Abort

            lines = message.split(MARKER, 1)[0].rstrip('\n').split('\n')
            if lines == ['']:
                raise Abort

            try:
                return cls._read_unsync_issues(lines, issues)
            except InputException as e:
                cls.error(e.message, nl=True)
                click.pause()

                continue