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


Python click.progressbar方法代码示例

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


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

示例1: index_json

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def index_json(filenames, force):
    """Index JSON-based vocabularies in Elasticsearch."""
    if not force:
        click.confirm(
            "Are you sure you want to index the vocabularies?",
            abort=True
        )
    source = "json"
    index_count = 0
    for filename in filenames:
        click.echo('indexing vocabularies in {}...'.format(filename))
        vocabularies = load_vocabularies(source, filename)
        cfg = current_app.config["RECORDS_REST_ENDPOINTS"][VOCABULARY_PID_TYPE]
        indexer = cfg["indexer_class"]()
        with click.progressbar(vocabularies) as bar:
            for vocabulary in bar:
                indexer.index(vocabulary)
        index_count += len(vocabularies)
    click.echo('indexed {} vocabularies'.format(index_count)) 
开发者ID:inveniosoftware,项目名称:invenio-app-ils,代码行数:21,代码来源:cli.py

示例2: index_opendefinition

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def index_opendefinition(loader, path, whitelist_status, force):
    """Index JSON-based vocabularies in Elasticsearch."""
    if not force:
        click.confirm(
            "Are you sure you want to index the vocabularies?",
            abort=True
        )
    index_count = 0
    click.echo('indexing licenses from loader {} and path {}...'.format(
        loader,
        path
    ))
    if whitelist_status:
        whitelist_status = whitelist_status.split(",")
    vocabularies = load_vocabularies(
        "opendefinition", loader, path, whitelist_status
    )
    cfg = current_app.config["RECORDS_REST_ENDPOINTS"][VOCABULARY_PID_TYPE]
    indexer = cfg["indexer_class"]()
    with click.progressbar(vocabularies) as bar:
        for vocabulary in bar:
            indexer.index(vocabulary)
    index_count += len(vocabularies)
    click.echo('indexed {} licenses'.format(index_count)) 
开发者ID:inveniosoftware,项目名称:invenio-app-ils,代码行数:26,代码来源:cli.py

示例3: progressbar

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def progressbar(self, label: str, total: int):
        bar = progressbar(
            length=total,
            fill_char=stream.green(self.BAR_FILLED_CHAR),
            empty_char=self.BAR_EMPTY_CHAR,
            show_percent=False,
            show_pos=True,
            label=label,
            bar_template="%(label)s %(bar)s %(info)s",
        )
        if self.parallel:
            executor = ThreadPoolExecutor()
        else:
            executor = DummyExecutor()
        with executor:
            try:
                yield bar, executor
            except KeyboardInterrupt:
                pass 
开发者ID:frostming,项目名称:pdm,代码行数:21,代码来源:synchronizers.py

示例4: start

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def start(self):
        itercontent = self._request.iter_content(chunk_size=self.CHUNK_SIZE)
        f = open(self._destination, "wb")
        chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))

        if util.is_ci():
            click.echo("Downloading...")
            for _ in range(0, chunks):
                f.write(next(itercontent))
        else:
            with click.progressbar(length=chunks, label="Downloading") as pb:
                for _ in pb:
                    f.write(next(itercontent))
        f.close()
        self._request.close()

        self._preserve_filemtime(self.get_lmtime()) 
开发者ID:bq,项目名称:web2board,代码行数:19,代码来源:downloader.py

示例5: progress_bar

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def progress_bar(self, arg):
        """Returns a pre-configured Click progress bar to use with downloads.
        If chapter uses separate page downloads, page download progress is
        shown (e.g. '7/20').
        """
        if self.uses_pages:
            iterable = arg
            length = None
        else:
            iterable = None
            length = arg

        click.echo('{c.alias} {c.chapter}'.format(c=self))
        return click.progressbar(iterable=iterable, length=length,
                                 fill_char='>', empty_char=' ',
                                 show_pos=self.uses_pages, show_percent=True) 
开发者ID:Hamuko,项目名称:cum,代码行数:18,代码来源:base.py

示例6: load_fixture

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def load_fixture(fixture_file):
    """
    Populate the database from a JSON file. Reads the JSON file FIXTURE_FILE
    and uses it to populate the database. Fuxture files should consist of a
    dictionary mapping database names to arrays of objects to store in those
    databases.
    """
    utils.check_for_local_server()
    local_url = config["local_server"]["url"]
    server = Server(local_url)
    fixture = json.load(fixture_file)
    for db_name, _items in fixture.items():
        db = server[db_name]
        with click.progressbar(
            _items, label=db_name, length=len(_items)
        ) as items:
            for item in items:
                item_id = item["_id"]
                if item_id in db:
                    old_item = db[item_id]
                    item["_rev"] = old_item["_rev"]
                    if item == old_item:
                        continue
                db[item_id] = item 
开发者ID:OpenAgricultureFoundation,项目名称:openag_python,代码行数:26,代码来源:__init__.py

示例7: run

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def run(self):
        models = {model: self.make_query(model).count() for model in StoredFileMixin.__subclasses__()}
        models = {model: total for model, total in models.iteritems() if total}
        labels = {model: cformat('Processing %{blue!}{}%{reset} (%{cyan}{}%{reset} rows)').format(model.__name__, total)
                  for model, total in models.iteritems()}
        max_length = max(len(x) for x in labels.itervalues())
        labels = {model: label.ljust(max_length) for model, label in labels.iteritems()}
        for model, total in sorted(models.items(), key=itemgetter(1)):
            with click.progressbar(self.query_chunked(model, 1000), length=total, label=labels[model],
                                   show_percent=True, show_pos=True) as objects:
                for obj in self.flush_rclone_iterator(objects, 1000):
                    try:
                        self.process_obj(obj)
                    except Exception as exc:
                        click.echo(cformat('\n%{red!}Error processing %{reset}%{yellow}{}%{red!}: %{reset}%{yellow!}{}')
                                   .format(obj, exc))
        click.secho('All done!', fg='green')
        click.echo('Add the following entries to your STORAGE_BACKENDS:')
        for bucket, data in sorted(self.buckets.viewitems(), key=itemgetter(0)):
            click.echo("'{}': 's3-readonly:host={},bucket={}',".format(
                data['backend'], self.s3_endpoint.replace('https://', ''), bucket)) 
开发者ID:indico,项目名称:indico-plugins,代码行数:23,代码来源:migrate.py

示例8: run

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def run(url):
    response = requests.get(url + '/', auth=('baseline', 'request'))
    if response.status_code != 401:

        click.echo(click.style('AEM authentication is not available', fg='red'))
        return

    click.echo(click.style('AEM authentication is available', fg='green'))
    with open(os.path.dirname(__file__) + '/../data/aem-default-creds.txt', 'r') as f:
        creds = map(string.strip, f.readlines())
        found = []
        with click.progressbar(creds, label='Checking default credentials') as bar:
            for line in bar:
                (login, password) = line.split(':')
                response = requests.post(url + '/', auth=(login, password))
                if response.status_code == 200:
                    found.append(line)
    if found:
        click.echo(click.style('Found {} default credentials!'.format(len(found)), fg='green'))
        for item in found:
            click.echo(click.style('{}'.format(item), fg='green')) 
开发者ID:Raz0r,项目名称:aemscan,代码行数:23,代码来源:bruteforce_default_credentials.py

示例9: convert

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def convert(association, ontology, output, association_file):
    click.echo("converting {}".format(association))

    rdfWriter = assoc_rdfgen.TurtleRdfWriter(label=os.path.basename(output.name))
    rdfTransformer = assoc_rdfgen.CamRdfTransform(writer=rdfWriter)
    parser_config = assocparser.AssocParserConfig(ontology=make_ontology(ontology))
    parser = _association_parser(association, parser_config)

    with open(association_file) as af:
        lines = sum(1 for line in af)

    with open(association_file) as af:
        associations = parser.association_generator(file=af)
        with click.progressbar(iterable=associations, length=lines) as assocs:
            for assoc in assocs:
                rdfTransformer.provenance()
                rdfTransformer.translate(assoc)

        click.echo("Writing ttl to disk")
        rdfWriter.serialize(destination=output) 
开发者ID:biolink,项目名称:ontobio,代码行数:22,代码来源:rdfgen.py

示例10: produce_gpi

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def produce_gpi(dataset, target_dir, gaf_path, ontology_graph):
    gafparser = GafParser()
    gafparser.config = assocparser.AssocParserConfig(
        ontology=ontology_graph
    )
    with open(gaf_path) as sg:
        lines = sum(1 for line in sg)

    gpi_path = os.path.join(os.path.split(gaf_path)[0], "{}.gpi".format(dataset))
    with open(gaf_path) as gf, open(gpi_path, "w") as gpi:
        click.echo("Using {} as the gaf to build gpi with".format(gaf_path))
        bridge = gafgpibridge.GafGpiBridge()
        gpiwriter = entitywriter.GpiWriter(file=gpi)
        gpi_cache = set()

        with click.progressbar(iterable=gafparser.association_generator(file=gf), length=lines) as associations:
            for association in associations:
                entity = bridge.convert_association(association)
                if entity not in gpi_cache and entity is not None:
                    # If the entity is not in the cache, add it and write it out
                    gpi_cache.add(entity)
                    gpiwriter.write_entity(entity)

    return gpi_path 
开发者ID:biolink,项目名称:ontobio,代码行数:26,代码来源:validate.py

示例11: cli

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def cli(obj, ids, query, filters, attributes):
    """Update alert attributes."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    with click.progressbar(ids, label='Updating {} alerts'.format(total)) as bar:
        for id in bar:
            client.update_attributes(id, dict(a.split('=') for a in attributes)) 
开发者ID:alerta,项目名称:python-alerta-client,代码行数:18,代码来源:cmd_update.py

示例12: cli

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def cli(obj, ids, query, filters, tags):
    """Add tags to alerts."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    with click.progressbar(ids, label='Tagging {} alerts'.format(total)) as bar:
        for id in bar:
            client.tag_alert(id, tags) 
开发者ID:alerta,项目名称:python-alerta-client,代码行数:18,代码来源:cmd_tag.py

示例13: cli

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def cli(obj, ids, query, filters):
    """Delete alerts."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if not (query or filters):
            click.confirm('Deleting all alerts. Do you want to continue?', abort=True)
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    with click.progressbar(ids, label='Deleting {} alerts'.format(total)) as bar:
        for id in bar:
            client.delete_alert(id) 
开发者ID:alerta,项目名称:python-alerta-client,代码行数:20,代码来源:cmd_delete.py

示例14: cli

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def cli(obj, ids, alert_ids, query, filters, text, delete):
    """Add or delete note to alerts."""
    client = obj['client']
    if delete:
        client.delete_alert_note(*delete)
    else:
        if alert_ids:
            total = len(alert_ids)
        else:
            if query:
                query = [('q', query)]
            else:
                query = build_query(filters)
            total, _, _ = client.get_count(query)
            alert_ids = [a.id for a in client.get_alerts(query)]

        with click.progressbar(alert_ids, label='Add note to {} alerts'.format(total)) as bar:
            for id in bar:
                client.alert_note(id, text=text) 
开发者ID:alerta,项目名称:python-alerta-client,代码行数:21,代码来源:cmd_note.py

示例15: cli

# 需要导入模块: import click [as 别名]
# 或者: from click import progressbar [as 别名]
def cli(obj, ids, query, filters, tags):
    """Remove tags from alerts."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    with click.progressbar(ids, label='Untagging {} alerts'.format(total)) as bar:
        for id in bar:
            client.untag_alert(id, tags) 
开发者ID:alerta,项目名称:python-alerta-client,代码行数:18,代码来源:cmd_untag.py


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