本文整理汇总了Python中click.Tuple方法的典型用法代码示例。如果您正苦于以下问题:Python click.Tuple方法的具体用法?Python click.Tuple怎么用?Python click.Tuple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类click
的用法示例。
在下文中一共展示了click.Tuple方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: data
# 需要导入模块: import click [as 别名]
# 或者: from click import Tuple [as 别名]
def data(self, index, role=QtCore.Qt.DisplayRole):
if role == QtCore.Qt.DisplayRole:
dstr = QtGui.QStandardItemModel.data(self, index, role)
if dstr == "" or dstr is None:
if isinstance(self.type, click.types.Tuple):
row = index.row()
if 0 <= row < len(self.type.types):
tp = self.type.types[row]
dstr = tp.name
else:
dstr = self.type.name
return dstr
if role == _GTypeRole:
tp = click.STRING
if isinstance(self.type, click.types.Tuple):
row = index.row()
if 0 <= row < len(self.type.types):
tp = self.type.types[row]
elif isinstance(self.type, click.types.ParamType):
tp = self.type
return tp
return QtGui.QStandardItemModel.data(self, index, role)
示例2: client
# 需要导入模块: import click [as 别名]
# 或者: from click import Tuple [as 别名]
def client(
policy: str,
rulefile: typing.List[str],
server_url: typing.List[str],
address: typing.Tuple[str, int],
):
from .rule import FilterRule
FilterRule(rulefile)
from .client import Client, set_policy, Pools, Pool
set_policy(policy)
Pools(
[
Pool(
"wss://" + s
if not s.startswith("ws://") and not s.startswith("wss://")
else s
)
for s in server_url
]
)
Client(address[0], address[1]).run()
示例3: server
# 需要导入模块: import click [as 别名]
# 或者: from click import Tuple [as 别名]
def server(address: typing.Tuple[str, int], userpass: typing.List[str]):
from .server import Server
Server(
{_userpass.split(":")[0]: _userpass.split(":")[1] for _userpass in userpass},
host=address[0],
port=address[1],
).run()
示例4: init
# 需要导入模块: import click [as 别名]
# 或者: from click import Tuple [as 别名]
def init():
"""Return top level command handler"""
@click.command()
@click.option('--cell', required=True,
envvar='TREADMILL_CELL',
callback=cli.handle_context_opt,
expose_value=False)
@click.option('--monitor', nargs=2, type=click.Tuple([str, int]),
multiple=True, required=True)
@click.option('--once', help='Run once.', is_flag=True, default=False)
@click.option('--interval', help='Wait interval between checks.',
default=_DEFAULT_INTERVAL)
@click.argument('name')
def controller(monitor, once, interval, name):
"""Control app monitors across cells"""
monitors = list(monitor)
while True:
intended_total = 0
actual_total = 0
intended = 0
for cellname, count in monitors:
if cellname == context.GLOBAL.cell:
intended = count
else:
actual = _count(cellname, name)
_LOGGER.info('state for cell %s, actual: %s, intended: %s',
cellname, actual, count)
intended_total += count
actual_total += actual
missing = intended_total - actual_total
# If there are missing instances, start them locally. If there are
# extra instances (missing < 0) just keep the indended state for
# the cell.
my_count = intended + max(0, missing)
_LOGGER.info('intended: %s, actual: %s, missing: %s, my count: %s',
intended_total, actual_total, missing, my_count)
_configure_monitor(name, my_count)
if once:
break
time.sleep(utils.to_seconds(interval))
return controller