Python click 模块,INT 实例源码

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

项目:textkit    作者:learntextvis    | 项目源码 | 文件源码
def tokens2counts(sep, limit, tokens):
    '''Count unique tokens in a list of tokens.
    Tokens are sorted by top counts.'''
    content = read_tokens(tokens)
    counts = sort_counts(get_counts(content))

    # we want the argument type to be an INT - but python only
    # has support for a float infinity. So if it the limit is negative,
    # it becomes infinite
    if limit < 0:
        limit = float('inf')

    # using csv writer to ensure proper encoding of the seperator.
    rows = [list(map(str, vals)) for ind, vals in enumerate(counts) if ind < limit]
    write_csv(rows, str(sep))
项目:adbons    作者:dbaelz    | 项目源码 | 文件源码
def option_device(func):
    @click.option("-d", "--device", type=click.STRING,
                  help="Use this device id.")
    @click.option("-i", "--index", type=click.INT,
                  help="Use this device index.")
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)
    return wrapper
项目:bdocker    作者:indigo-dc    | 项目源码 | 文件源码
def job_option(f):
    return click.option(
        '--jobid', '-j', default=None,
        type=click.INT, help='The job ID'
    )(f)
项目:bdocker    作者:indigo-dc    | 项目源码 | 文件源码
def user_credentials(f):
    out = click.argument("uid", type=click.INT
                         )(f)
    return out
项目:uhu    作者:updatehub    | 项目源码 | 文件源码
def test_int_type(self):
        class Option(IntegerOption):
            metadata = 'name'
            cli = ['--name']

        click_option = ClickObjectOption(Option)
        self.assertEqual(click_option.type, click.INT)