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


Python textui.indent方法代码示例

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


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

示例1: tell

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def tell(msg, type=INFO, indnt=0, utype=TERMINAL, text_output=None, reverse=True):
    if utype == WEB:
        if reverse:
            return msg + "\n" + text_output
        else:
            return text_output + "\n" + msg
    else:
        if indnt <= 0:
            if clint_present:
                puts(text_colors[type](msg))
            else:
                print(msg)
        else:
            if clint_present:
                with indent(indnt):
                    puts(text_colors[type](msg))
            else:
                for i in range(0, indnt):
                    msg = '  ' + msg
                print(msg) 
开发者ID:gcallah,项目名称:indras_net,代码行数:22,代码来源:user.py

示例2: stop

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def stop():

    # Shortcut to ask master password before output Configuration message
    decrypt(config().get('Source', 'password'))

    output_cli_message("Check active subscriptions in Destination nodes", color='cyan')
    puts("")
    subscriptions = get_destination_subscriptions()
    with indent(4, quote=' >'):
        for s in iter(subscriptions.keys()):
            output_cli_message(s)
            message = colored.yellow("Active") if subscriptions[s] else colored.green("Stopped")
            print(output_cli_result(message))
            if subscriptions[s]:
                with indent(4, quote=' '):
                    output_cli_message("Launch stop command")
                    syncronize_sequences(s)  # must be done BEFORE stopping subscriptions
                    print(output_cli_result(stop_subscription(s), 8)) 
开发者ID:rtshome,项目名称:pgrepup,代码行数:20,代码来源:stop.py

示例3: update

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def update(user, password, lang=None):
    langs = getlangs(lang)
    puts(u"Updating %s" % ', '.join(langs))
    for loc in langs:
        with indent(2):
            puts(u"Downloading PO for %s" % loc)
        url = (u'https://www.transifex.com/projects/p/formhub/'
               u'resource/django/l/%(lang)s/download/for_use/' % {'lang': loc})
        try:
            tmp_po_file = download_with_login(url, TX_LOGIN_URL,
                                              login=user, password=password,
                                              ext='po',
                                              username_field='identification',
                                              password_field='password',
                                              form_id=1)
            po_file = os.path.join(REPO_ROOT, 'locale', loc,
                                   'LC_MESSAGES', 'django.po')
            with indent(2):
                puts(u"Copying downloaded file to %s" % po_file)
            shutil.move(tmp_po_file, po_file)
        except Exception as e:
            puts(colored.red(u"Unable to update %s "
                             u"from Transifex: %r" % (loc, e)))
        puts(colored.green("sucesssfuly retrieved %s" % loc))
    compile_mo(langs) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:27,代码来源:i18ntool.py

示例4: usage

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def usage(exit=True, code=1):
    print(u"i18n wrapper script for formhub.\n")
    with indent(4):
        puts(colored.yellow(u",/i18ntool.py add --lang <lang>"))
        puts(u"Create required files for enabling translation "
             u"of language with code <lang>\n")

        puts(colored.yellow(u"./i18ntool.py refresh [--lang <lang>]"))
        puts(u"Update the PO file for <lang> based on code.\n"
             u"<lang> is optionnal as we only use EN and do "
             u"all translations in Transifex.\n")

        puts(colored.yellow(u"./i18ntool.py update --user <tx_user> "
                            u"--password <tx_pass> [--lang <lang>]"))
        puts(u"Downloads new PO files for <lang> (or all) from Transifex "
             u"then compiles new MO files\n")

        puts(colored.yellow(u"./i18ntool.py compile [--lang <lang>]"))
        puts(u"Compiles all PO files for <lang> (or all) into MO files.\n"
             u"Not required unless you want to.\n")

    if exit:
        sys.exit(code) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:25,代码来源:i18ntool.py

示例5: print_goal

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def print_goal(goal, achieved=False, level=None, indent=2):
    """ Print a goals description with its icon. Achieved (True/False) will choose the correct icon
    from the goal. If a level is specified, a tracker line will be added under the icon showing
    the current level out of the required level for the goal. If level is > the required level,
    achieved will be set to true.
    """
    from clint.textui import puts
    from clint.textui import indent as _indent
    from clint.textui.cols import columns, console_width
    if level is not None and level >= goal['level']:
        achieved = True
    icon = (goal['icon'].achieved() if achieved else goal['icon'].unachieved()).split('\n')
    maxiw = max([len(str(_)) for _ in icon])
    descw = console_width({})-maxiw-(indent + 4)
    desc = '{0}\n{1}\n\n{2}'.format(goal['name'], '-'*len(goal['name']),
                                    columns([goal['description'], descw])).split('\n')
    if level is not None:
        if level > goal['level']:
            level = goal['level']
        maxitw = max([len(_) for _ in icon])
        icon.append(("%d/%d" % (level, goal['level'])).center(maxitw))
    with _indent(indent):
        for i, d in _zip_longest(icon, desc):
            puts("{1:{0}}    {2}".format(maxiw, str(i) if i is not None else "",
                                         d.strip() if d is not None else "")) 
开发者ID:PacketPerception,项目名称:pychievements,代码行数:27,代码来源:cli.py

示例6: print_goals

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def print_goals(achievement_or_iter, indent=2):
    """
    Displays all of the available goals registered for the given achievement(s)
    """
    from clint.textui import puts
    from clint.textui.cols import console_width
    from clint.textui import indent as _indent
    if _isclass(achievement_or_iter) and issubclass(achievement_or_iter, Achievement):
        achievement_or_iter = [achievement_or_iter]

    for achievement in achievement_or_iter:
        with _indent(indent):
            puts("{0}\n{1}\n".format(achievement.name, '='*(console_width({})-indent-2)))
        for goal in achievement.goals:
            print_goal(goal, True, indent=indent)
            puts("\n") 
开发者ID:PacketPerception,项目名称:pychievements,代码行数:18,代码来源:cli.py

示例7: assert_files

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def assert_files(migration, alloc_docs_by_db, ansible_context):
    files_by_node = get_files_for_assertion(alloc_docs_by_db)
    expected_files_vars = os.path.abspath(os.path.join(migration.working_dir, 'assert_vars.yml'))
    with open(expected_files_vars, 'w') as f:
        yaml.safe_dump({
            'files_by_node': files_by_node,
            'couch_data_dir': migration.couchdb2_data_dir,
        }, f, indent=2)

    play_path = os.path.join(PLAY_DIR, 'assert_couch_files.yml')
    return_code = run_ansible_playbook(
        migration.target_environment, play_path, ansible_context,
        always_skip_check=True,
        quiet=True,
        unknown_args=['-e', '@{}'.format(expected_files_vars)]
    )
    return return_code == 0 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:19,代码来源:couchdb.py

示例8: describe

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def describe(migration):
    puts(u'\nMembership')
    with indent():
        puts(get_membership(migration.target_couch_config).get_printable())
    puts(u'\nDB Info')
    print_db_info(migration.target_couch_config)

    puts(u'\nShard allocation')
    diff_with_db = diff_plan(migration)
    if diff_with_db:
        puts(color_highlight('DB allocation differs from plan:\n'))
        puts("{}\n\n".format(diff_with_db))
    else:
        puts(color_success('DB allocation matches plan.'))
        print_shard_table([
            get_shard_allocation(migration.target_couch_config, db_name)
            for db_name in sorted(get_db_list(migration.target_couch_config.get_control_node()))
        ])
    return 0 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:21,代码来源:couchdb.py

示例9: run

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def run(self, args, unknown_args):
        environment = get_environment(args.env_name)
        couch_config = get_couch_config(environment)

        puts(u'\nMembership')
        with indent():
            puts(get_membership(couch_config).get_printable())

        puts(u'\nDB Info')
        print_db_info(couch_config)

        puts(u'\nShard allocation')
        print_shard_table([
            get_shard_allocation(couch_config, db_name)
            for db_name in sorted(get_db_list(couch_config.get_control_node()))
        ])
        return 0 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:19,代码来源:ops_tool.py

示例10: filter_out_deprecated_pillows

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def filter_out_deprecated_pillows(environment, pillows):
    deprecated_pillows = ['GeographyFluffPillow', 'FarmerRecordFluffPillow']
    good_pillows = {}
    bad_pillows = set()
    for host, pillow_configs in pillows.items():
        good_pillows[host] = {}
        for pillow_name, pillow_config in pillow_configs.items():
            if pillow_name not in deprecated_pillows:
                good_pillows[host][pillow_name] = pillow_config
            else:
                bad_pillows.add(pillow_name)
    if bad_pillows:
        puts(color_warning(
            'This environment references deprecated pillow(s):\n'
        ))
        with indent():
            for pillow_name in sorted(bad_pillows):
                puts(color_warning('- {}'.format(pillow_name)))
        puts(color_warning(
            '\nThis pillows are unused and no longer needed.\n'
            'To get rid of this warning, remove those pillows from {}'
            .format(environment.paths.app_processes_yml)
        ))
    return good_pillows 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:26,代码来源:app_processes.py

示例11: resolve_reference_genome

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def resolve_reference_genome(loc):
    """
        Resolve location of reference genome file.
    """

    if loc is None:
        message("You must specify a genome:")
        output_genome_list()
        exit()

    if os.path.exists(loc):
        return loc
    else:
        if loc in get_genome_list():
            reference_location = "{gd}/{loc}/{loc}.fa.gz".format(gd = get_genome_directory(), loc = loc)
            with indent(4):
                puts_err(colored.green("\nUsing reference located at %s\n" % reference_location))
            return reference_location
        else:
            with indent(4):
                exit(puts_err(colored.red("\nGenome '%s' does not exist\n" % loc))) 
开发者ID:AndersenLab,项目名称:VCF-kit,代码行数:23,代码来源:reference.py

示例12: seq_type

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def seq_type(filename):
    """
        Resolves sequence filetype using extension.
    """
    filename, ext = os.path.splitext(filename.lower())
    if ext in [".fasta", ".fa"]:
        extension = 'fasta'
    elif ext in [".fastq",".fq"]:
        extension = 'fastq'
    elif ext in [".ab1", '.abi']:
        extension = 'abi'
    else:
        raise Exception("Unknown sequence file type: " + filename)

    with indent(4):
        puts_err(colored.green("\nReading sequences as %s\n" % extension.upper()))
    return extension 
开发者ID:AndersenLab,项目名称:VCF-kit,代码行数:19,代码来源:call.py

示例13: txn_preference_chooser

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def txn_preference_chooser(user_prompt=DEFAULT_PROMPT):
    puts('How quickly do you want this transaction to confirm? The higher the miner preference, the higher the transaction fee.')
    TXN_PREFERENCES = (
            ('high', '1-2 blocks to confirm'),
            ('medium', '3-6 blocks to confirm'),
            ('low', '7+ blocks to confirm'),
            #  ('zero', 'no fee, may not ever confirm (advanced users only)'),
            )
    for cnt, pref_desc in enumerate(TXN_PREFERENCES):
        pref, desc = pref_desc
        with indent(2):
            puts(colored.cyan('%s (%s priority): %s' % (cnt+1, pref, desc)))
    choice_int = choice_prompt(
            user_prompt=user_prompt,
            acceptable_responses=range(1, len(TXN_PREFERENCES)+1),
            default_input='1',  # high pref
            show_default=True,
            )
    return TXN_PREFERENCES[int(choice_int)-1][0] 
开发者ID:blockcypher,项目名称:bcwallet,代码行数:21,代码来源:cl_utils.py

示例14: load_plugins

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def load_plugins(self):
        with indent(4):
            logger.debug("PLUGINS: %s", self._settings['PLUGINS'])
            for plugin in self._settings['PLUGINS']:
                for class_name, cls in import_string(plugin):
                    if issubclass(cls, MachineBasePlugin) and cls is not MachineBasePlugin:
                        logger.debug("Found a Machine plugin: {}".format(plugin))
                        storage = PluginStorage(class_name)
                        instance = cls(SlackClient(), self._settings, storage)
                        missing_settings = self._register_plugin(class_name, instance)
                        if missing_settings:
                            show_invalid(class_name)
                            with indent(4):
                                error_msg = "The following settings are missing: {}".format(
                                    ", ".join(missing_settings)
                                )
                                puts(colored.red(error_msg))
                                puts(colored.red("This plugin will not be loaded!"))
                            del instance
                        else:
                            instance.init()
                            show_valid(class_name)
        self._storage.set('manual', dill.dumps(self._help)) 
开发者ID:DandyDev,项目名称:slack-machine,代码行数:25,代码来源:core.py

示例15: fix

# 需要导入模块: from clint import textui [as 别名]
# 或者: from clint.textui import indent [as 别名]
def fix():

    # Shortcut to ask master password before output Configuration message
    decrypt(config().get('Source', 'password'))

    output_cli_message("Find Source cluster's databases with tables without primary key/unique index...", color='cyan')
    print

    db_conn = connect('Source')
    with indent(4, quote=' >'):
        for db in get_cluster_databases(db_conn):
            output_cli_message(db)
            s_db_conn = connect('Source', db_name=db)
            tables_without_unique = False
            with indent(4, quote=' '):
                for table in get_database_tables(s_db_conn):
                    t_r = table_has_primary_key(s_db_conn, table['schema'], table['table'])
                    if not t_r:
                        tables_without_unique = True
                        print
                        output_cli_message("Found %s.%s without primary key" % (table['schema'], table['table']))
                        result = add_table_unique_index(s_db_conn, table['schema'], table['table'])
                        print(output_cli_result(
                            colored.green('Added %s field' % get_unique_field_name()) if result else False,
                            compensation=4
                        ))

            if not tables_without_unique:
                print(output_cli_result(True)) 
开发者ID:rtshome,项目名称:pgrepup,代码行数:31,代码来源:fix.py


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