我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用click.INT。
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))
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
def job_option(f): return click.option( '--jobid', '-j', default=None, type=click.INT, help='The job ID' )(f)
def user_credentials(f): out = click.argument("uid", type=click.INT )(f) return out
def test_int_type(self): class Option(IntegerOption): metadata = 'name' cli = ['--name'] click_option = ClickObjectOption(Option) self.assertEqual(click_option.type, click.INT)