Merge branch 'master' of github.com:The-Compiler/qutebrowser
This commit is contained in:
commit
b0bd8170e0
@ -86,7 +86,7 @@ Useful utilities
|
|||||||
Checkers
|
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.
|
unittests and several linters/checkers.
|
||||||
|
|
||||||
Currently, the following tools will be invoked when you run `tox`:
|
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
|
* John ShaggyTwoDope Jenkins
|
||||||
* Jimmy
|
* Jimmy
|
||||||
* Zach-Button
|
* Zach-Button
|
||||||
|
* Martin Tournoij
|
||||||
* rikn00
|
* rikn00
|
||||||
* Patric Schmitz
|
* Patric Schmitz
|
||||||
* Martin Zimmermann
|
* Martin Zimmermann
|
||||||
|
@ -70,7 +70,7 @@ def run(args):
|
|||||||
sys.exit(usertypes.Exit.ok)
|
sys.exit(usertypes.Exit.ok)
|
||||||
|
|
||||||
if args.temp_basedir:
|
if args.temp_basedir:
|
||||||
args.basedir = tempfile.mkdtemp()
|
args.basedir = tempfile.mkdtemp(prefix='qutebrowser-basedir-')
|
||||||
|
|
||||||
quitter = Quitter(args)
|
quitter = Quitter(args)
|
||||||
objreg.register('quitter', quitter)
|
objreg.register('quitter', quitter)
|
||||||
|
@ -487,12 +487,25 @@ class WebView(QWebView):
|
|||||||
old_scroll_pos = self.scroll_pos
|
old_scroll_pos = self.scroll_pos
|
||||||
flags = QWebPage.FindFlags(flags)
|
flags = QWebPage.FindFlags(flags)
|
||||||
found = self.findText(text, flags)
|
found = self.findText(text, flags)
|
||||||
|
backward = flags & QWebPage.FindBackward
|
||||||
|
|
||||||
if not found and not flags & QWebPage.HighlightAllOccurrences and text:
|
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 "
|
message.error(self.win_id, "Text '{}' not found on "
|
||||||
"page!".format(text), immediately=True)
|
"page!".format(text), immediately=True)
|
||||||
else:
|
else:
|
||||||
backward = int(flags) & QWebPage.FindBackward
|
|
||||||
|
|
||||||
def check_scroll_pos():
|
def check_scroll_pos():
|
||||||
"""Check if the scroll position got smaller and show info."""
|
"""Check if the scroll position got smaller and show info."""
|
||||||
if not backward and self.scroll_pos < old_scroll_pos:
|
if not backward and self.scroll_pos < old_scroll_pos:
|
||||||
|
@ -287,7 +287,7 @@ class Command:
|
|||||||
A list of args.
|
A list of args.
|
||||||
"""
|
"""
|
||||||
args = []
|
args = []
|
||||||
name = param.name.rstrip('_')
|
name = param.name.rstrip('_').replace('_', '-')
|
||||||
shortname = annotation_info.flag or name[0]
|
shortname = annotation_info.flag or name[0]
|
||||||
if len(shortname) != 1:
|
if len(shortname) != 1:
|
||||||
raise ValueError("Flag '{}' of parameter {} (command {}) must be "
|
raise ValueError("Flag '{}' of parameter {} (command {}) must be "
|
||||||
|
@ -122,7 +122,8 @@ class ExternalEditor(QObject):
|
|||||||
raise ValueError("Already editing a file!")
|
raise ValueError("Already editing a file!")
|
||||||
self._text = text
|
self._text = text
|
||||||
try:
|
try:
|
||||||
self._oshandle, self._filename = tempfile.mkstemp(text=True)
|
self._oshandle, self._filename = tempfile.mkstemp(
|
||||||
|
text=True, prefix='qutebrowser-editor-')
|
||||||
if text:
|
if text:
|
||||||
encoding = config.get('general', 'editor-encoding')
|
encoding = config.get('general', 'editor-encoding')
|
||||||
with open(self._filename, 'w', encoding=encoding) as f:
|
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
|
# https://bugreports.qt-project.org/browse/QTBUG-30298
|
||||||
"QNetworkReplyImplPrivate::error: Internal problem, this method must "
|
"QNetworkReplyImplPrivate::error: Internal problem, this method must "
|
||||||
"only be called once.",
|
"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
|
# Sometimes indicates missing text, but most of the time harmless
|
||||||
"load glyph failed ",
|
"load glyph failed ",
|
||||||
# Harmless, see https://bugreports.qt-project.org/browse/QTBUG-42479
|
# Harmless, see https://bugreports.qt-project.org/browse/QTBUG-42479
|
||||||
@ -282,7 +280,11 @@ def qt_message_handler(msg_type, context, msg):
|
|||||||
# Hopefully harmless
|
# Hopefully harmless
|
||||||
'"Method "GetAll" with signature "s" on interface '
|
'"Method "GetAll" with signature "s" on interface '
|
||||||
'"org.freedesktop.DBus.Properties" doesn\'t exist',
|
'"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):
|
if any(msg.strip().startswith(pattern) for pattern in suppressed_msgs):
|
||||||
level = logging.DEBUG
|
level = logging.DEBUG
|
||||||
|
@ -28,6 +28,7 @@ import sys
|
|||||||
import glob
|
import glob
|
||||||
import subprocess
|
import subprocess
|
||||||
import platform
|
import platform
|
||||||
|
import filecmp
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
@ -58,6 +59,22 @@ def get_ignored_files(directory, files):
|
|||||||
return filtered
|
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):
|
def link_pyqt(sys_path, venv_path):
|
||||||
"""Symlink the systemwide PyQt/sip into the venv.
|
"""Symlink the systemwide PyQt/sip into the venv.
|
||||||
|
|
||||||
@ -75,16 +92,24 @@ def link_pyqt(sys_path, venv_path):
|
|||||||
for fn, required in files:
|
for fn, required in files:
|
||||||
source = os.path.join(sys_path, fn)
|
source = os.path.join(sys_path, fn)
|
||||||
dest = os.path.join(venv_path, fn)
|
dest = os.path.join(venv_path, fn)
|
||||||
|
|
||||||
if not os.path.exists(source):
|
if not os.path.exists(source):
|
||||||
if required:
|
if required:
|
||||||
raise FileNotFoundError(source)
|
raise FileNotFoundError(source)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if os.path.exists(dest):
|
if os.path.exists(dest):
|
||||||
if os.path.isdir(dest) and not os.path.islink(dest):
|
if needs_update(source, dest):
|
||||||
shutil.rmtree(dest)
|
remove(dest)
|
||||||
else:
|
else:
|
||||||
os.unlink(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.name == 'nt':
|
||||||
if os.path.isdir(source):
|
if os.path.isdir(source):
|
||||||
shutil.copytree(source, dest, ignore=get_ignored_files,
|
shutil.copytree(source, dest, ignore=get_ignored_files,
|
||||||
@ -97,6 +122,14 @@ def link_pyqt(sys_path, venv_path):
|
|||||||
os.symlink(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):
|
def get_python_lib(executable, venv=False):
|
||||||
"""Get the python site-packages directory for the given executable.
|
"""Get the python site-packages directory for the given executable.
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ def _get_command_doc_args(cmd, parser):
|
|||||||
yield "* +'{}'+: {}".format(name, parser.arg_descs[arg])
|
yield "* +'{}'+: {}".format(name, parser.arg_descs[arg])
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
raise KeyError("No description for arg {} of command "
|
raise KeyError("No description for arg {} of command "
|
||||||
"'{}'!".format(e, cmd.name))
|
"'{}'!".format(e, cmd.name)) from e
|
||||||
|
|
||||||
if cmd.opt_args:
|
if cmd.opt_args:
|
||||||
yield ""
|
yield ""
|
||||||
@ -193,9 +193,9 @@ def _get_command_doc_args(cmd, parser):
|
|||||||
try:
|
try:
|
||||||
yield '* +*{}*+, +*{}*+: {}'.format(short_flag, long_flag,
|
yield '* +*{}*+, +*{}*+: {}'.format(short_flag, long_flag,
|
||||||
parser.arg_descs[arg])
|
parser.arg_descs[arg])
|
||||||
except KeyError:
|
except KeyError as e:
|
||||||
raise KeyError("No description for arg {} of command "
|
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):
|
def _get_command_doc_count(cmd, parser):
|
||||||
@ -213,9 +213,9 @@ def _get_command_doc_count(cmd, parser):
|
|||||||
yield "==== count"
|
yield "==== count"
|
||||||
try:
|
try:
|
||||||
yield parser.arg_descs[cmd.count_arg]
|
yield parser.arg_descs[cmd.count_arg]
|
||||||
except KeyError:
|
except KeyError as e:
|
||||||
raise KeyError("No description for count arg {!r} of command "
|
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):
|
def _get_command_doc_notes(cmd):
|
||||||
|
Loading…
Reference in New Issue
Block a user