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


Python click.group方法代码示例

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


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

示例1: list_groups

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def list_groups(ctx):
    """
    (deprecated) List user groups.

    Please use `pdtools cloud list-groups`.
    """
    url = ctx.obj['pdserver_url'] + "/api/groups"
    result = pdserver_request('GET', url)
    groups = result.json()

    for group in groups:
        print("{} {}".format(group['_id'], group['name']))

        print("  Users:")
        for user_id in group['users']:
            print("    {}".format(user_id))

        print("  Routers:")
        for router_id in group['routers']:
            print("    {}".format(router_id)) 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:22,代码来源:groups.py

示例2: test_completion

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def test_completion():
    @click.group()
    def foo_group():
        pass

    @foo_group.command()
    def foo_cmd():
        pass

    @click.group()
    def foobar_group():
        pass

    @foobar_group.command()
    def foobar_cmd():
        pass

    c = ClickCompleter(click.CommandCollection(sources=[foo_group, foobar_group]))
    completions = list(c.get_completions(Document(u"foo")))

    assert set(x.text for x in completions) == set([u"foo_cmd", u"foobar_cmd"]) 
开发者ID:click-contrib,项目名称:click-repl,代码行数:23,代码来源:test_command_collection.py

示例3: test_completion

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def test_completion():
    @click.group()
    def root_command():
        pass

    @root_command.group()
    def first_level_command():
        pass

    @first_level_command.command()
    def second_level_command_one():
        pass

    @first_level_command.command()
    def second_level_command_two():
        pass

    c = ClickCompleter(root_command)
    completions = list(c.get_completions(Document(u"first_level_command ")))

    assert set(x.text for x in completions) == set(
        [u"second_level_command_one", u"second_level_command_two"]
    ) 
开发者ID:click-contrib,项目名称:click-repl,代码行数:25,代码来源:test_basic.py

示例4: _detect_wifi_ssid

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def _detect_wifi_ssid():
    system = _system()
    if system not in SUPPORTED_SYSTEMS:
        return False, 'Unknown operation system {0}'.format(system)

    if system == 'Darwin':
        command = ['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport', '-I']
        pattern = re.compile(r' SSID: (?P<ssid>.+)')
    elif system == 'Linux':
        command = ['nmcli', '-t', '-f', 'active,ssid', 'dev', 'wifi']
        pattern = re.compile(r"yes:'(?P<ssid>.+)'")
    else:
        command = ['netsh', 'wlan', 'show', 'interfaces']
        pattern = re.compile(r' SSID.+: (?P<ssid>.+)\r')

    rs = _exec(command)
    match = re.search(pattern, rs)
    if not match:
        return False, rs

    return True, match.group('ssid') 
开发者ID:cls1991,项目名称:ng,代码行数:23,代码来源:ng.py

示例5: invoke

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def invoke(resource, action, api_key, **kwargs):
    """Attempt to invoke the provided action on each resource.

        Arguments:
            resource: Object defining a Sfx resource (chart, dashboard, dashboard group, etc)
            action: String to create, update, read, or delete a resource
            api_key: String

        Returns:
            The response from the action taken.
    """
    res = resource.with_api_token(api_key)
    try:
        action_fn = getattr(res, action)
    except AttributeError:
        msg = "Attempted to execute unsupported action '{0}' on resource '{1}'."
        click.echo(msg.format(action, resource.__get__('name')))
        exit()

    return action_fn(**kwargs) 
开发者ID:Nike-Inc,项目名称:signal_analog,代码行数:22,代码来源:cli.py

示例6: parse_data

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def parse_data(stats_dir):
    def parse_file(file):
        experiment = None
        base_file = path.basename(file)
        m = SUMMARY_REGEX.match(base_file)
        if m:
            experiment = 'all features'
        m = ANSWER_REGEX.match(base_file)
        if m:
            experiment = m.group(1)
        if experiment is None:
            raise ValueError('Incorrect file name argument: {}'.format(base_file))
        with open(file) as f:
            data = json.load(f)
            return seq(data.items()).map(lambda kv: {
                'experiment': experiment,
                'result': kv[0].replace('Answer.', ''),
                'score': kv[1]
            })

    rows = seq(glob(path.join(stats_dir, 'test*.json')))\
        .sorted().flat_map(parse_file).to_pandas()
    return rows 
开发者ID:Pinafore,项目名称:qb,代码行数:25,代码来源:performance.py

示例7: test_ClickOption_failsWithPrompt

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def test_ClickOption_failsWithPrompt(runner):
  @click.group()
  def isitfit(): pass

  @click.group()
  @click.option('--prompt', default='foo', prompt='my prompt', type=str)
  def cost(prompt): pass

  @click.command()
  def analyze(): pass

  cost.add_command(analyze)
  isitfit.add_command(cost)

  # invoke and assert
  result = runner.invoke(isitfit, ['cost', '--help'])
  assert False # the invoke above is expected to halt at the prompt and fail, but not working as expected ATM 
开发者ID:autofitcloud,项目名称:isitfit,代码行数:19,代码来源:test_clickDescendents.py

示例8: test_IsitfitOption_worksWithPrompt

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def test_IsitfitOption_worksWithPrompt(runner):
  """
  This test is the working counter-part of test_ClickOption_failsWithPrompt which was expected to fail
  """
  from isitfit.cli.click_descendents import isitfit_option_base

  @click.group()
  def isitfit(): pass

  # Note that in the below, callback is not set
  @click.group()
  @isitfit_option_base('--prompt', default='foo', prompt='my prompt', type=str)
  def cost(prompt): pass

  @click.command()
  def analyze(): pass

  cost.add_command(analyze)
  isitfit.add_command(cost)

  # invoke and assert
  result = runner.invoke(isitfit, ['cost', '--help'])
  assert not result.exception 
开发者ID:autofitcloud,项目名称:isitfit,代码行数:25,代码来源:test_clickDescendents.py

示例9: test_IsitfitOptionProfile_ok

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def test_IsitfitOptionProfile_ok(runner):
  from isitfit.cli.click_descendents import isitfit_option_profile

  @click.group()
  def isitfit(): pass

  @click.group()
  @isitfit_option_profile()
  def cost(prompt): pass

  @click.command()
  def analyze(): pass

  cost.add_command(analyze)
  isitfit.add_command(cost)

  # invoke and assert
  result = runner.invoke(isitfit, ['cost', '--help'])
  assert not result.exception 
开发者ID:autofitcloud,项目名称:isitfit,代码行数:21,代码来源:test_clickDescendents.py

示例10: check_links

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def check_links(script_path: str) -> None:
    with open(script_path, "r") as f:
        contents = f.read()
    link_matches = list(MARKDOWN_URL_REGEX.finditer(contents))
    for link_match in link_matches:
        url = link_match.group(0).rstrip(")").lstrip("(")
        req = urllib.request.Request(url, headers={"User-Agent": "Magic Browser"})
        logging.info(f"Checking link [{url}]")
        try:
            urllib.request.urlopen(req, timeout=5)
        except urllib.error.HTTPError as e:
            raise ValueError(f"Bad link [{url}] found in {script_path}: {e}")
        except Exception as e:
            logging.warning(
                f"SKIPPING: Could not access [{url}] found in {script_path}: {e}"
            ) 
开发者ID:snorkel-team,项目名称:snorkel-tutorials,代码行数:18,代码来源:build.py

示例11: cmd_share

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def cmd_share(filename, role, type, email, domain, discoverable):
    if type in ['user', 'group'] and email is None:
        print('--email is required for user or group type.')
        sys.exit(1)
    elif type == 'domain' and domain is None:
        print('--domain is required for domain type.')
        sys.exit(1)
    config_dir = _get_current_config_dir()
    id = get_id_by_path(filename)
    cmd = '{exe} --config {config} share'.format(
        exe=DRIVE_EXE, config=config_dir)
    if role:
        cmd += ' --role {role}'.format(role=role)
    if type:
        cmd += ' --type {type}'.format(type=type)
    if email:
        cmd += ' --email {email}'.format(email=email)
    if domain:
        cmd += ' --domain {domain}'.format(domain=domain)
    if discoverable:
        cmd += ' --discoverable'
    # if revoke:
    #     cmd += ' --revoke'
    cmd += ' {id}'.format(id=id)
    subprocess.call(cmd, shell=True) 
开发者ID:wkentaro,项目名称:gshell,代码行数:27,代码来源:__init__.py

示例12: group_grant

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def group_grant(ctx, userid, groupid):
    """Add a user into a group (grant privilege)

    \b
    Parameters:
        <userid> - username, AoR or SIP URI for subscriber
        <groupid> - group name
    """
    udata = parse_user_spec(ctx, userid)
    ctx.vlog(
        "Adding user [%s@%s] in group [%s]",
        udata["username"],
        udata["domain"],
        groupid,
    )
    e = create_engine(ctx.gconfig.get("db", "rwurl"))
    e.execute(
        "insert into grp (username, domain, grp) values (%s, %s, %s)",
        udata["username"],
        udata["domain"],
        groupid,
    ) 
开发者ID:kamailio,项目名称:kamcli,代码行数:24,代码来源:cmd_group.py

示例13: address_list

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def address_list(ctx, mode, group):
    """Show details for address records in memory

    \b
    Parameters:
        <group> - address group
    """
    if mode == "all":
        command_ctl(ctx, "permissions.addressDump", [])
        command_ctl(ctx, "permissions.subnetDump", [])
        command_ctl(ctx, "permissions.domainDump", [])
    elif mode == "addresses":
        command_ctl(ctx, "permissions.addressDump", [])
    elif mode == "subnets":
        command_ctl(ctx, "permissions.subnetDump", [])
    elif mode == "domains":
        command_ctl(ctx, "permissions.domainDump", [])
    else:
        command_ctl(ctx, "permissions.addressDump", []) 
开发者ID:kamailio,项目名称:kamcli,代码行数:21,代码来源:cmd_address.py

示例14: error

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def error():
    """
    Get or share information about an error

    If you'd like to dig into an error more yourself,
    you can get the last few lines of context about it
    from `cci error info`.

    If you'd like to submit it to a developer for conversation,
    you can use the `cci error gist` command. Just make sure
    that your GitHub access token has the 'create gist' scope.

    For more information on working with errors in CumulusCI visit:
    https://cumulusci.readthedocs.io/en/latest/features.html#working-with-errors
    """


# Commands for group: project 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:20,代码来源:cci.py

示例15: service_info

# 需要导入模块: import click [as 别名]
# 或者: from click import group [as 别名]
def service_info(runtime, service_name, plain):
    try:
        plain = plain or runtime.global_config.cli__plain_output
        service_config = runtime.keychain.get_service(service_name)
        service_data = [["Key", "Value"]]
        service_data.extend(
            [
                [click.style(k, bold=True), str(v)]
                for k, v in service_config.config.items()
            ]
        )
        wrap_cols = ["Value"] if not plain else None
        service_table = CliTable(service_data, title=service_name, wrap_cols=wrap_cols)
        service_table._table.inner_heading_row_border = False
        service_table.echo(plain)
    except ServiceNotConfigured:
        click.echo(
            "{0} is not configured for this project.  Use service connect {0} to configure.".format(
                service_name
            )
        )


# Commands for group: org 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:26,代码来源:cci.py


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