本文整理汇总了Python中qutebrowser.utils.utils.elide函数的典型用法代码示例。如果您正苦于以下问题:Python elide函数的具体用法?Python elide怎么用?Python elide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elide函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __repr__
def __repr__(self):
try:
url = utils.elide(self.url().toDisplayString(QUrl.EncodeUnicode),
100)
except (AttributeError, RuntimeError) as exc:
url = '<{}>'.format(exc.__class__.__name__)
return utils.get_repr(self, tab_id=self.tab_id, url=url)
开发者ID:Harrison97,项目名称:qutebrowser,代码行数:7,代码来源:browsertab.py
示例2: wait_for_load_finished_url
def wait_for_load_finished_url(self, url, *, timeout=None,
load_status='success'):
"""Wait until a URL has finished loading."""
__tracebackhide__ = (lambda e: e.errisinstance(
testprocess.WaitForTimeout))
if timeout is None:
if 'CI' in os.environ:
timeout = 15000
else:
timeout = 5000
# We really need the same representation that the webview uses in its
# __repr__
qurl = QUrl(url)
if not qurl.isValid():
raise ValueError("Invalid URL {}: {}".format(url,
qurl.errorString()))
url = utils.elide(qurl.toDisplayString(QUrl.EncodeUnicode), 100)
assert url
pattern = re.compile(
r"(load status for <qutebrowser\.browser\..* "
r"tab_id=\d+ url='{url}/?'>: LoadStatus\.{load_status}|fetch: "
r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format(
load_status=re.escape(load_status), url=re.escape(url)))
try:
self.wait_for(message=pattern, timeout=timeout)
except testprocess.WaitForTimeout:
raise testprocess.WaitForTimeout("Timed out while waiting for {} "
"to be loaded".format(url))
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:32,代码来源:quteprocess.py
示例3: _wait_for_new
def _wait_for_new(self, timeout, do_skip, **kwargs):
"""Wait for a log message which doesn't exist yet.
Called via wait_for.
"""
__tracebackhide__ = lambda e: e.errisinstance(WaitForTimeout)
message = kwargs.get('message', None)
if message is not None:
elided = quteutils.elide(repr(message), 50)
self._log("\n----> Waiting for {} in the log".format(elided))
spy = QSignalSpy(self.new_data)
elapsed_timer = QElapsedTimer()
elapsed_timer.start()
while True:
# Skip if there are pending messages causing a skip
self._maybe_skip()
got_signal = spy.wait(timeout)
if not got_signal or elapsed_timer.hasExpired(timeout):
msg = "Timed out after {}ms waiting for {!r}.".format(
timeout, kwargs)
if do_skip:
pytest.skip(msg)
else:
raise WaitForTimeout(msg)
match = self._wait_for_match(spy, kwargs)
if match is not None:
if message is not None:
self._log("----> found it")
return match
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:32,代码来源:testprocess.py
示例4: _on_navigation_request
def _on_navigation_request(
self,
navigation: usertypes.NavigationRequest
) -> None:
"""Handle common acceptNavigationRequest code."""
url = utils.elide(navigation.url.toDisplayString(), 100)
log.webview.debug("navigation request: url {}, type {}, is_main_frame "
"{}".format(url,
navigation.navigation_type,
navigation.is_main_frame))
if not navigation.url.isValid():
# Also a WORKAROUND for missing IDNA 2008 support in QUrl, see
# https://bugreports.qt.io/browse/QTBUG-60364
if navigation.navigation_type == navigation.Type.link_clicked:
msg = urlutils.get_errstring(navigation.url,
"Invalid link clicked")
message.error(msg)
self.data.open_target = usertypes.ClickTarget.normal
log.webview.debug("Ignoring invalid URL {} in "
"acceptNavigationRequest: {}".format(
navigation.url.toDisplayString(),
navigation.url.errorString()))
navigation.accepted = False
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:26,代码来源:browsertab.py
示例5: __repr__
def __repr__(self):
try:
url = utils.elide(self.url().toDisplayString(QUrl.EncodeUnicode),
100)
except AttributeError:
url = '<AttributeError>'
return utils.get_repr(self, tab_id=self.tab_id, url=url)
开发者ID:meles5,项目名称:qutebrowser,代码行数:7,代码来源:browsertab.py
示例6: wait_for_load_finished
def wait_for_load_finished(self, path, *, port=None, https=False,
timeout=None, load_status='success'):
"""Wait until any tab has finished loading."""
__tracebackhide__ = True
if timeout is None:
if 'CI' in os.environ:
timeout = 15000
else:
timeout = 5000
url = self.path_to_url(path, port=port, https=https)
# We really need the same representation that the webview uses in its
# __repr__
url = utils.elide(QUrl(url).toDisplayString(QUrl.EncodeUnicode), 100)
pattern = re.compile(
r"(load status for <qutebrowser\.browser\.webview\.WebView "
r"tab_id=\d+ url='{url}/?'>: LoadStatus\.{load_status}|fetch: "
r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format(
load_status=re.escape(load_status), url=re.escape(url)))
try:
self.wait_for(message=pattern, timeout=timeout)
except testprocess.WaitForTimeout:
raise testprocess.WaitForTimeout("Timed out while waiting for {} "
"to be loaded".format(url))
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:26,代码来源:quteprocess.py
示例7: __repr__
def __repr__(self) -> str:
try:
qurl = self.url()
url = qurl.toDisplayString(QUrl.EncodeUnicode) # type: ignore
except (AttributeError, RuntimeError) as exc:
url = '<{}>'.format(exc.__class__.__name__)
else:
url = utils.elide(url, 100)
return utils.get_repr(self, tab_id=self.tab_id, url=url)
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:9,代码来源:browsertab.py
示例8: wait_for_load_finished
def wait_for_load_finished(self, path, timeout=15000):
"""Wait until any tab has finished loading."""
url = self.path_to_url(path)
# We really need the same representation that the webview uses in its
# __repr__
url = utils.elide(QUrl(url).toDisplayString(QUrl.EncodeUnicode), 100)
pattern = re.compile(
r"(load status for <qutebrowser.browser.webview.WebView "
r"tab_id=\d+ url='{url}'>: LoadStatus.success|fetch: "
r"PyQt5.QtCore.QUrl\('{url}'\) -> .*)".format(url=re.escape(url)))
self.wait_for(message=pattern, timeout=timeout)
开发者ID:shawa,项目名称:qutebrowser,代码行数:11,代码来源:quteprocess.py
示例9: _on_navigation_request
def _on_navigation_request(self, navigation):
"""Handle common acceptNavigationRequest code."""
url = utils.elide(navigation.url.toDisplayString(), 100)
log.webview.debug("navigation request: url {}, type {}, is_main_frame "
"{}".format(url,
navigation.navigation_type,
navigation.is_main_frame))
if (navigation.navigation_type == navigation.Type.link_clicked and
not navigation.url.isValid()):
msg = urlutils.get_errstring(navigation.url,
"Invalid link clicked")
message.error(msg)
self.data.open_target = usertypes.ClickTarget.normal
navigation.accepted = False
开发者ID:Harrison97,项目名称:qutebrowser,代码行数:15,代码来源:browsertab.py
示例10: _js_cb_single
def _js_cb_single(self, callback, js_elem):
"""Handle a found focus elem coming from JS and call the real callback.
Args:
callback: The callback to call with the found element.
Called with a WebEngineElement or None.
js_elem: The element serialized from javascript.
"""
debug_str = ('None' if js_elem is None
else utils.elide(repr(js_elem), 1000))
log.webview.debug("Got element from JS: {}".format(debug_str))
if js_elem is None:
callback(None)
else:
elem = webengineelem.WebEngineElement(js_elem, tab=self._tab)
callback(elem)
开发者ID:Harrison97,项目名称:qutebrowser,代码行数:17,代码来源:webenginetab.py
示例11: wait_for_load_finished
def wait_for_load_finished(self, path, *, port=None, https=False, timeout=None, load_status="success"):
"""Wait until any tab has finished loading."""
if timeout is None:
if "CI" in os.environ:
timeout = 15000
else:
timeout = 5000
url = self.path_to_url(path, port=port, https=https)
# We really need the same representation that the webview uses in its
# __repr__
url = utils.elide(QUrl(url).toDisplayString(QUrl.EncodeUnicode), 100)
pattern = re.compile(
r"(load status for <qutebrowser\.browser\.webview\.WebView "
r"tab_id=\d+ url='{url}'>: LoadStatus\.{load_status}|fetch: "
r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format(load_status=re.escape(load_status), url=re.escape(url))
)
self.wait_for(message=pattern, timeout=timeout)
开发者ID:Link-Satonaka,项目名称:qutebrowser,代码行数:18,代码来源:quteprocess.py
示例12: wait_for_load_finished_url
def wait_for_load_finished_url(self, url, *, timeout=None,
load_status='success', after=None):
"""Wait until a URL has finished loading."""
__tracebackhide__ = (lambda e: e.errisinstance(
testprocess.WaitForTimeout))
if timeout is None:
if 'CI' in os.environ:
timeout = 15000
else:
timeout = 5000
qurl = QUrl(url)
if not qurl.isValid():
raise ValueError("Invalid URL {}: {}".format(url,
qurl.errorString()))
if (qurl == QUrl('about:blank') and
not qtutils.version_check('5.10', compiled=False)):
# For some reason, we don't get a LoadStatus.success for
# about:blank sometimes.
# However, if we do this for Qt 5.10, we get general testsuite
# instability as site loads get reported with about:blank...
pattern = "Changing title for idx * to 'about:blank'"
else:
# We really need the same representation that the webview uses in
# its __repr__
url = utils.elide(qurl.toDisplayString(QUrl.EncodeUnicode), 100)
assert url
pattern = re.compile(
r"(load status for <qutebrowser\.browser\..* "
r"tab_id=\d+ url='{url}/?'>: LoadStatus\.{load_status}|fetch: "
r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format(
load_status=re.escape(load_status), url=re.escape(url)))
try:
self.wait_for(message=pattern, timeout=timeout, after=after)
except testprocess.WaitForTimeout:
raise testprocess.WaitForTimeout("Timed out while waiting for {} "
"to be loaded".format(url))
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:41,代码来源:quteprocess.py
示例13: __repr__
def __repr__(self):
url = utils.elide(self.url().toDisplayString(QUrl.EncodeUnicode), 100)
return utils.get_repr(self, tab_id=self.tab_id, url=url)
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:3,代码来源:webview.py
示例14: test_elided
def test_elided(self):
"""Test eliding with a string which should get elided."""
assert utils.elide('foobar', 3) == 'fo' + self.ELLIPSIS
开发者ID:andor44,项目名称:qutebrowser,代码行数:3,代码来源:test_utils.py
示例15: test_fits
def test_fits(self):
"""Test eliding with a string which fits exactly."""
assert utils.elide('foo', 3) == 'foo'
开发者ID:andor44,项目名称:qutebrowser,代码行数:3,代码来源:test_utils.py
示例16: test_length_one
def test_length_one(self):
"""Test eliding to 1 char which should yield ..."""
assert utils.elide('foo', 1) == self.ELLIPSIS
开发者ID:andor44,项目名称:qutebrowser,代码行数:3,代码来源:test_utils.py
示例17: test_length_one
def test_length_one(self):
"""Test eliding to 1 char which should yield ..."""
self.assertEqual(utils.elide('foo', 1), self.ELLIPSIS)
开发者ID:larryhynes,项目名称:qutebrowser,代码行数:3,代码来源:test_utils.py
示例18: test_fits
def test_fits(self):
"""Test eliding with a string which fits exactly."""
self.assertEqual(utils.elide('foo', 3), 'foo')
开发者ID:larryhynes,项目名称:qutebrowser,代码行数:3,代码来源:test_utils.py
示例19: test_elided
def test_elided(self):
"""Test eliding with a string which should get elided."""
self.assertEqual(utils.elide('foobar', 3), 'fo' + self.ELLIPSIS)
开发者ID:larryhynes,项目名称:qutebrowser,代码行数:3,代码来源:test_utils.py
示例20: __repr__
def __repr__(self):
url = utils.elide(self.url().toDisplayString(), 50)
return utils.get_repr(self, tab_id=self.tab_id, url=url)
开发者ID:larryhynes,项目名称:qutebrowser,代码行数:3,代码来源:webview.py
注:本文中的qutebrowser.utils.utils.elide函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论