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

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

项目:pipenv    作者:pypa    | 项目源码 | 文件源码
def init():
    """patch click to support enhanced completion"""
    import click
    click.types.ParamType.complete = param_type_complete
    click.types.Choice.complete = choice_complete
    click.core.MultiCommand.get_command_short_help = multicommand_get_command_short_help
    click.core._bashcomplete = _shellcomplete
项目:q2cli    作者:qiime2    | 项目源码 | 文件源码
def __init__(self, name, repr, ast, default=NoDefault, description=None):
        import q2cli.util

        super().__init__(name, repr, ast, default=default,
                         description=description)
        # TODO: just create custom click.ParamType to avoid this silliness
        if ast['type'] == 'collection':
            ast, = ast['fields']
        self.type = q2cli.util.convert_primitive(ast)
项目:two1-python    作者:21dotco    | 项目源码 | 文件源码
def __init__(self):
        click.ParamType.__init__(self)
项目:two1-python    作者:21dotco    | 项目源码 | 文件源码
def __init__(self):
        click.ParamType.__init__(self)
项目:two1-python    作者:21dotco    | 项目源码 | 文件源码
def __init__(self):
        click.ParamType.__init__(self)
项目:globus-cli    作者:globus    | 项目源码 | 文件源码
def convert(self, value, param, ctx):
        """
        ParamType.convert() is the actual processing method that takes a
        provided parameter and parses it.
        """
        # passthrough conditions: None or already processed
        if value is None or isinstance(value, tuple):
            return value

        # split the value on the first colon, leave the rest intact
        splitval = value.split(':', 1)
        # first element is the endpoint_id
        endpoint_id = click.UUID(splitval[0])

        # get the second element, defaulting to `None` if there was no colon in
        # the original value
        try:
            path = splitval[1]
        except IndexError:
            path = None
        # coerce path="" to path=None
        # means that we treat "enpdoint_id" and "endpoint_id:" equivalently
        path = path or None

        if path is None and self.path_required:
            self.fail('The path component is required', param=param)

        return (endpoint_id, path)
项目:click-completion    作者:click-contrib    | 项目源码 | 文件源码
def init():
    """patch click to support enhanced completion"""
    import click
    click.types.ParamType.complete = param_type_complete
    click.types.Choice.complete = choice_complete
    click.core.MultiCommand.get_command_short_help = multicommand_get_command_short_help
    click.core._bashcomplete = _shellcomplete