Make debug text more compact
This commit is contained in:
parent
f8151bc8ed
commit
be460afc1c
@ -49,6 +49,24 @@ def elide(text, length):
|
||||
return text[:length - 1] + '\u2026'
|
||||
|
||||
|
||||
def compact_text(text, elidelength=None):
|
||||
"""Remove leading whitespace and newlines from a text and maybe elide it.
|
||||
|
||||
FIXME: Add tests.
|
||||
|
||||
Args:
|
||||
text: The text to compact.
|
||||
elidelength: To how many chars to elide.
|
||||
"""
|
||||
out = []
|
||||
for line in text.splitlines():
|
||||
out.append(line.strip())
|
||||
out = ''.join(out)
|
||||
if elidelength is not None:
|
||||
out = elide(out, elidelength)
|
||||
return out
|
||||
|
||||
|
||||
def read_file(filename):
|
||||
"""Get the contents of a file contained with qutebrowser.
|
||||
|
||||
|
@ -31,8 +31,9 @@ from PyQt5.QtCore import QRect, QUrl
|
||||
from PyQt5.QtWebKit import QWebElement
|
||||
|
||||
import qutebrowser.utils.log as log
|
||||
from qutebrowser.utils.usertypes import enum
|
||||
import qutebrowser.config.config as config
|
||||
from qutebrowser.utils.usertypes import enum
|
||||
from qutebrowser.utils.misc import compact_text
|
||||
|
||||
|
||||
Group = enum('all', 'links', 'images', 'editable', 'url', 'prevnext_rel',
|
||||
@ -250,7 +251,7 @@ def is_editable(elem, strict=False):
|
||||
# pylint: disable=too-many-return-statements
|
||||
roles = ('combobox', 'textbox')
|
||||
log.misc.debug("Checking if element is editable: {}".format(
|
||||
elem.toOuterXml()))
|
||||
compact_text(elem.toOuterXml(), 500)))
|
||||
tag = elem.tagName().lower()
|
||||
if is_content_editable(elem) and is_writable(elem):
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user