本文整理匯總了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