本文整理汇总了Python中qutebrowser.commands.cmdutils.check_overflow函数的典型用法代码示例。如果您正苦于以下问题:Python check_overflow函数的具体用法?Python check_overflow怎么用?Python check_overflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_overflow函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_bad
def test_bad(self):
int32_max = 2 ** 31 - 1
with pytest.raises(cmdexc.CommandError) as excinfo:
cmdutils.check_overflow(int32_max + 1, "int")
expected_str = "Numeric argument is too large for internal int " "representation."
assert str(excinfo.value) == expected_str
开发者ID:rumpelsepp,项目名称:qutebrowser,代码行数:9,代码来源:test_cmdutils.py
示例2: scroll
def scroll(self, dx: {'type': float}, dy: {'type': float}, count=1):
"""Scroll the current tab by 'count * dx/dy'.
Args:
dx: How much to scroll in x-direction.
dy: How much to scroll in x-direction.
count: multiplier
"""
dx *= count
dy *= count
cmdutils.check_overflow(dx, 'int')
cmdutils.check_overflow(dy, 'int')
self._current_widget().page().currentFrame().scroll(dx, dy)
开发者ID:andor44,项目名称:qutebrowser,代码行数:13,代码来源:commands.py
示例3: scroll_page
def scroll_page(self, x: {'type': float}, y: {'type': float}, count=1):
"""Scroll the frame page-wise.
Args:
x: How many pages to scroll to the right.
y: How many pages to scroll down.
count: multiplier
"""
frame = self._current_widget().page().currentFrame()
size = frame.geometry()
dx = count * x * size.width()
dy = count * y * size.height()
cmdutils.check_overflow(dx, 'int')
cmdutils.check_overflow(dy, 'int')
frame.scroll(dx, dy)
开发者ID:andor44,项目名称:qutebrowser,代码行数:15,代码来源:commands.py
示例4: _cntwidget
def _cntwidget(self, count=None):
"""Return a widget based on a count/idx.
Args:
count: The tab index, or None.
Return:
The current widget if count is None.
The widget with the given tab ID if count is given.
None if no widget was found.
"""
tabbed_browser = self._tabbed_browser()
if count is None:
return tabbed_browser.currentWidget()
elif 1 <= count <= self._count():
cmdutils.check_overflow(count + 1, 'int')
return tabbed_browser.widget(count - 1)
else:
return None
开发者ID:helenst,项目名称:qutebrowser,代码行数:19,代码来源:commands.py
示例5: tab_focus
def tab_focus(self, index: {'type': (int, 'last')}=None, count=None):
"""Select the tab given as argument/[count].
Args:
index: The tab index to focus, starting with 1. The special value
`last` focuses the last focused tab.
count: The tab index to focus, starting with 1.
"""
if index == 'last':
self._tab_focus_last()
return
try:
idx = cmdutils.arg_or_count(index, count, default=1,
countzero=self._count())
except ValueError as e:
raise cmdexc.CommandError(e)
cmdutils.check_overflow(idx + 1, 'int')
if 1 <= idx <= self._count():
self._set_current_index(idx - 1)
else:
raise cmdexc.CommandError("There's no tab with index {}!".format(
idx))
开发者ID:andor44,项目名称:qutebrowser,代码行数:22,代码来源:commands.py
示例6: tab_move
def tab_move(self, direction: {'type': ('+', '-')}=None,
count: {'special': 'count'}=None):
"""Move the current tab.
Args:
direction: `+` or `-` for relative moving, not given for absolute
moving.
count: If moving absolutely: New position (default: 0)
If moving relatively: Offset.
"""
if direction is None:
new_idx = self._tab_move_absolute(count)
elif direction in '+-':
try:
new_idx = self._tab_move_relative(direction, count)
except ValueError:
raise cmdexc.CommandError("Count must be given for relative "
"moving!")
else:
raise cmdexc.CommandError("Invalid direction '{}'!".format(
direction))
if not 0 <= new_idx < self._count():
raise cmdexc.CommandError("Can't move tab to position {}!".format(
new_idx))
tabbed_browser = self._tabbed_browser()
tab = self._current_widget()
cur_idx = self._current_index()
icon = tabbed_browser.tabIcon(cur_idx)
label = tabbed_browser.tabText(cur_idx)
cmdutils.check_overflow(cur_idx, 'int')
cmdutils.check_overflow(new_idx, 'int')
tabbed_browser.setUpdatesEnabled(False)
try:
tabbed_browser.removeTab(cur_idx)
tabbed_browser.insertTab(new_idx, tab, icon, label)
self._set_current_index(new_idx)
finally:
tabbed_browser.setUpdatesEnabled(True)
开发者ID:helenst,项目名称:qutebrowser,代码行数:38,代码来源:commands.py
示例7: test_bad
def test_bad(self):
int32_max = 2 ** 31 - 1
with pytest.raises(cmdexc.CommandError, match="Numeric argument is "
"too large for internal int representation."):
cmdutils.check_overflow(int32_max + 1, 'int')
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:6,代码来源:test_cmdutils.py
示例8: test_good
def test_good(self):
cmdutils.check_overflow(1, 'int')
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:2,代码来源:test_cmdutils.py
注:本文中的qutebrowser.commands.cmdutils.check_overflow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论