Merge branch 'master' of github.com:The-Compiler/qutebrowser
This commit is contained in:
commit
b0bd8170e0
@ -86,7 +86,7 @@ Useful utilities
|
||||
Checkers
|
||||
~~~~~~~~
|
||||
|
||||
qutbebrowser uses http://tox.readthedocs.org/en/latest/[tox] to run its
|
||||
qutebrowser uses http://tox.readthedocs.org/en/latest/[tox] to run its
|
||||
unittests and several linters/checkers.
|
||||
|
||||
Currently, the following tools will be invoked when you run `tox`:
|
||||
|
@ -144,6 +144,7 @@ Contributors, sorted by the number of commits in descending order:
|
||||
* John ShaggyTwoDope Jenkins
|
||||
* Jimmy
|
||||
* Zach-Button
|
||||
* Martin Tournoij
|
||||
* rikn00
|
||||
* Patric Schmitz
|
||||
* Martin Zimmermann
|
||||
|
@ -70,7 +70,7 @@ def run(args):
|
||||
sys.exit(usertypes.Exit.ok)
|
||||
|
||||
if args.temp_basedir:
|
||||
args.basedir = tempfile.mkdtemp()
|
||||
args.basedir = tempfile.mkdtemp(prefix='qutebrowser-basedir-')
|
||||
|
||||
quitter = Quitter(args)
|
||||
objreg.register('quitter', quitter)
|
||||
|
@ -487,12 +487,25 @@ class WebView(QWebView):
|
||||
old_scroll_pos = self.scroll_pos
|
||||
flags = QWebPage.FindFlags(flags)
|
||||
found = self.findText(text, flags)
|
||||
if not found and not flags & QWebPage.HighlightAllOccurrences and text:
|
||||
message.error(self.win_id, "Text '{}' not found on "
|
||||
"page!".format(text), immediately=True)
|
||||
else:
|
||||
backward = int(flags) & QWebPage.FindBackward
|
||||
backward = flags & QWebPage.FindBackward
|
||||
|
||||
if not found and not flags & QWebPage.HighlightAllOccurrences and text:
|
||||
# User disabled wrapping; but findText() just returns False. If we
|
||||
# have a selection, we know there's a match *somewhere* on the page
|
||||
if (not flags & QWebPage.FindWrapsAroundDocument and
|
||||
self.hasSelection()):
|
||||
if not backward:
|
||||
message.warning(self.win_id, "Search hit BOTTOM without "
|
||||
"match for: {}".format(text),
|
||||
immediately=True)
|
||||
else:
|
||||
message.warning(self.win_id, "Search hit TOP without "
|
||||
"match for: {}".format(text),
|
||||
immediately=True)
|
||||
else:
|
||||
message.error(self.win_id, "Text '{}' not found on "
|
||||
"page!".format(text), immediately=True)
|
||||
else:
|
||||
def check_scroll_pos():
|
||||
"""Check if the scroll position got smaller and show info."""
|
||||
if not backward and self.scroll_pos < old_scroll_pos:
|
||||
|
@ -287,7 +287,7 @@ class Command:
|
||||
A list of args.
|
||||
"""
|
||||
args = []
|
||||
name = param.name.rstrip('_')
|
||||
name = param.name.rstrip('_').replace('_', '-')
|
||||
shortname = annotation_info.flag or name[0]
|
||||
if len(shortname) != 1:
|
||||
raise ValueError("Flag '{}' of parameter {} (command {}) must be "
|
||||
|
@ -122,7 +122,8 @@ class ExternalEditor(QObject):
|
||||
raise ValueError("Already editing a file!")
|
||||
self._text = text
|
||||
try:
|
||||
self._oshandle, self._filename = tempfile.mkstemp(text=True)
|
||||
self._oshandle, self._filename = tempfile.mkstemp(
|
||||
text=True, prefix='qutebrowser-editor-')
|
||||
if text:
|
||||
encoding = config.get('general', 'editor-encoding')
|
||||
with open(self._filename, 'w', encoding=encoding) as f:
|
||||
|
@ -269,8 +269,6 @@ def qt_message_handler(msg_type, context, msg):
|
||||
# https://bugreports.qt-project.org/browse/QTBUG-30298
|
||||
"QNetworkReplyImplPrivate::error: Internal problem, this method must "
|
||||
"only be called once.",
|
||||
# Not much information about this, but it seems harmless
|
||||
'QXcbWindow: Unhandled client message: "_GTK_LOAD_ICONTHEMES"',
|
||||
# Sometimes indicates missing text, but most of the time harmless
|
||||
"load glyph failed ",
|
||||
# Harmless, see https://bugreports.qt-project.org/browse/QTBUG-42479
|
||||
@ -282,7 +280,11 @@ def qt_message_handler(msg_type, context, msg):
|
||||
# Hopefully harmless
|
||||
'"Method "GetAll" with signature "s" on interface '
|
||||
'"org.freedesktop.DBus.Properties" doesn\'t exist',
|
||||
'WOFF support requires QtWebKit to be built with zlib support.'
|
||||
'WOFF support requires QtWebKit to be built with zlib support.',
|
||||
# Weird Enlightment/GTK X extensions
|
||||
'QXcbWindow: Unhandled client message: "_E_',
|
||||
'QXcbWindow: Unhandled client message: "_ECORE_',
|
||||
'QXcbWindow: Unhandled client message: "_GTK_',
|
||||
)
|
||||
if any(msg.strip().startswith(pattern) for pattern in suppressed_msgs):
|
||||
level = logging.DEBUG
|
||||
|
@ -28,6 +28,7 @@ import sys
|
||||
import glob
|
||||
import subprocess
|
||||
import platform
|
||||
import filecmp
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
@ -58,6 +59,22 @@ def get_ignored_files(directory, files):
|
||||
return filtered
|
||||
|
||||
|
||||
def needs_update(source, dest):
|
||||
"""Check if a file to be linked/copied needs to be updated."""
|
||||
if os.path.islink(dest):
|
||||
# No need to delete a link and relink -> skip this
|
||||
return False
|
||||
elif os.path.isdir(dest):
|
||||
diffs = filecmp.dircmp(source, dest)
|
||||
ignored = get_ignored_files(source, diffs.left_only)
|
||||
has_new_files = set(ignored) != set(diffs.left_only)
|
||||
return (has_new_files or diffs.right_only or
|
||||
diffs.common_funny or diffs.diff_files or
|
||||
diffs.funny_files)
|
||||
else:
|
||||
return not filecmp.cmp(source, dest)
|
||||
|
||||
|
||||
def link_pyqt(sys_path, venv_path):
|
||||
"""Symlink the systemwide PyQt/sip into the venv.
|
||||
|
||||
@ -75,26 +92,42 @@ def link_pyqt(sys_path, venv_path):
|
||||
for fn, required in files:
|
||||
source = os.path.join(sys_path, fn)
|
||||
dest = os.path.join(venv_path, fn)
|
||||
|
||||
if not os.path.exists(source):
|
||||
if required:
|
||||
raise FileNotFoundError(source)
|
||||
else:
|
||||
continue
|
||||
|
||||
if os.path.exists(dest):
|
||||
if os.path.isdir(dest) and not os.path.islink(dest):
|
||||
shutil.rmtree(dest)
|
||||
if needs_update(source, dest):
|
||||
remove(dest)
|
||||
else:
|
||||
os.unlink(dest)
|
||||
if os.name == 'nt':
|
||||
if os.path.isdir(source):
|
||||
shutil.copytree(source, dest, ignore=get_ignored_files,
|
||||
copy_function=verbose_copy)
|
||||
else:
|
||||
print('{} -> {}'.format(source, dest))
|
||||
shutil.copy(source, dest)
|
||||
continue
|
||||
|
||||
copy_or_link(source, dest)
|
||||
|
||||
|
||||
def copy_or_link(source, dest):
|
||||
"""Copy or symlink source to dest."""
|
||||
if os.name == 'nt':
|
||||
if os.path.isdir(source):
|
||||
shutil.copytree(source, dest, ignore=get_ignored_files,
|
||||
copy_function=verbose_copy)
|
||||
else:
|
||||
print('{} -> {}'.format(source, dest))
|
||||
os.symlink(source, dest)
|
||||
shutil.copy(source, dest)
|
||||
else:
|
||||
print('{} -> {}'.format(source, dest))
|
||||
os.symlink(source, dest)
|
||||
|
||||
|
||||
def remove(filename):
|
||||
"""Remove a given filename, regardless of whether it's a file or dir."""
|
||||
if os.path.isdir(filename):
|
||||
shutil.rmtree(filename)
|
||||
else:
|
||||
os.unlink(filename)
|
||||
|
||||
|
||||
def get_python_lib(executable, venv=False):
|
||||
|
@ -184,7 +184,7 @@ def _get_command_doc_args(cmd, parser):
|
||||
yield "* +'{}'+: {}".format(name, parser.arg_descs[arg])
|
||||
except KeyError as e:
|
||||
raise KeyError("No description for arg {} of command "
|
||||
"'{}'!".format(e, cmd.name))
|
||||
"'{}'!".format(e, cmd.name)) from e
|
||||
|
||||
if cmd.opt_args:
|
||||
yield ""
|
||||
@ -193,9 +193,9 @@ def _get_command_doc_args(cmd, parser):
|
||||
try:
|
||||
yield '* +*{}*+, +*{}*+: {}'.format(short_flag, long_flag,
|
||||
parser.arg_descs[arg])
|
||||
except KeyError:
|
||||
except KeyError as e:
|
||||
raise KeyError("No description for arg {} of command "
|
||||
"'{}'!".format(e, cmd.name))
|
||||
"'{}'!".format(e, cmd.name)) from e
|
||||
|
||||
|
||||
def _get_command_doc_count(cmd, parser):
|
||||
@ -213,9 +213,9 @@ def _get_command_doc_count(cmd, parser):
|
||||
yield "==== count"
|
||||
try:
|
||||
yield parser.arg_descs[cmd.count_arg]
|
||||
except KeyError:
|
||||
except KeyError as e:
|
||||
raise KeyError("No description for count arg {!r} of command "
|
||||
"{!r}!".format(cmd.count_arg, cmd.name))
|
||||
"{!r}!".format(cmd.count_arg, cmd.name)) from e
|
||||
|
||||
|
||||
def _get_command_doc_notes(cmd):
|
||||
|
Loading…
Reference in New Issue
Block a user