autodetect.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:rcli 作者: contains-io 项目源码 文件源码
def _append_commands(dct,  # type: typing.Dict[str, typing.Set[str]]
                     module_name,  # type: str
                     commands  # type:typing.Iterable[_EntryPoint]
                     ):
    # type: (...) -> None
    """Append entry point strings representing the given Command objects.

    Args:
        dct: The dictionary to append with entry point strings. Each key will
            be a primary command with a value containing a list of entry point
            strings representing a Command.
        module_name: The name of the module in which the command object
            resides.
        commands: A list of Command objects to convert to entry point strings.
    """
    for command in commands:
        entry_point = '{command}{subcommand} = {module}{callable}'.format(
            command=command.command,
            subcommand=(':{}'.format(command.subcommand)
                        if command.subcommand else ''),
            module=module_name,
            callable=(':{}'.format(command.callable)
                      if command.callable else ''),
        )
        dct.setdefault(command.command, set()).add(entry_point)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号