Rename utils.qt to utils.qtutils.

This commit is contained in:
Florian Bruhin 2014-08-26 20:25:11 +02:00
parent d9a8cbe7ad
commit 8bd64382bd
28 changed files with 37 additions and 55 deletions

View File

@ -43,9 +43,9 @@ from qutebrowser.network import qutescheme, proxy
from qutebrowser.browser import quickmarks, cookies, downloads
from qutebrowser.widgets import mainwindow, console, crash
from qutebrowser.keyinput import modeparsers, keyparser, modeman
from qutebrowser.utils import log, version, message, utilcmds, readline, utils
from qutebrowser.utils import (log, version, message, utilcmds, readline,
utils, qtutils)
from qutebrowser.utils import url as urlutils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import usertypes as utypes

View File

@ -34,8 +34,7 @@ from qutebrowser.commands import utils as cmdutils
from qutebrowser.commands import exceptions as cmdexc
from qutebrowser.config import config
from qutebrowser.browser import hints, quickmarks
from qutebrowser.utils import message, webelem, editor, usertypes, log
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import message, webelem, editor, usertypes, log, qtutils
from qutebrowser.utils import url as urlutils

View File

@ -30,8 +30,7 @@ from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
from qutebrowser.config import config
from qutebrowser.commands import utils as cmdutils
from qutebrowser.commands import exceptions as cmdexc
from qutebrowser.utils import message, http, usertypes, log, utils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import message, http, usertypes, log, utils, qtutils
class DownloadItem(QObject):

View File

@ -32,8 +32,7 @@ from qutebrowser.keyinput import modeman
from qutebrowser.utils import message, webelem
from qutebrowser.commands import userscripts
from qutebrowser.commands import exceptions as cmdexc
from qutebrowser.utils import usertypes, log
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import usertypes, log, qtutils
ElemTuple = collections.namedtuple('ElemTuple', 'elem, label')

View File

@ -29,8 +29,7 @@ import collections
from PyQt5.QtCore import QStandardPaths, QUrl
from qutebrowser.utils import message, usertypes, utils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import message, usertypes, utils, qtutils
from qutebrowser.commands import utils as cmdutils
from qutebrowser.commands import exceptions as cmdexc
from qutebrowser.config import lineparser

View File

@ -30,8 +30,7 @@ from PyQt5.QtWebKitWidgets import QWebPage
from qutebrowser.config import config
from qutebrowser.network import networkmanager
from qutebrowser.utils import message, usertypes, log, http, utils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import message, usertypes, log, http, utils, qtutils
class BrowserPage(QWebPage):

View File

@ -26,8 +26,7 @@ Module attributes:
import inspect
import collections
from qutebrowser.utils import usertypes
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import usertypes, qtutils
from qutebrowser.commands import command
from qutebrowser.commands import exceptions as cmdexc

View File

@ -32,7 +32,7 @@ import collections
from qutebrowser.config import conftypes as typ
from qutebrowser.config import sections as sect
from qutebrowser.config.value import SettingValue
from qutebrowser.utils.qt import MAXVALS
from qutebrowser.utils.qtutils import MAXVALS
FIRST_COMMENT = r"""

View File

@ -26,8 +26,7 @@ Module attributes:
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QStandardItemModel, QStandardItem
from qutebrowser.utils import usertypes
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import usertypes, qtutils
Role = usertypes.enum('Role', 'marks', 'sort', start=Qt.UserRole, is_int=True)

View File

@ -24,8 +24,7 @@ from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication
from qutebrowser.config import config, configdata
from qutebrowser.models import basecompletion
from qutebrowser.commands import utils as cmdutils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import log
from qutebrowser.utils import log, qtutils
class SettingSectionCompletionModel(basecompletion.BaseCompletionModel):

View File

@ -26,8 +26,7 @@ Contains:
from PyQt5.QtCore import QSortFilterProxyModel, QModelIndex
from qutebrowser.models import basecompletion as completion
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import log
from qutebrowser.utils import log, qtutils
class CompletionFilterModel(QSortFilterProxyModel):

View File

@ -24,8 +24,7 @@ from PyQt5.QtCore import (pyqtSlot, Qt, QVariant, QAbstractListModel,
from PyQt5.QtWidgets import QApplication
from qutebrowser.config import config
from qutebrowser.utils import usertypes
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import usertypes, qtutils
Role = usertypes.enum('Role', 'item', start=Qt.UserRole, is_int=True)

View File

@ -29,8 +29,7 @@ import tempfile
from PyQt5.QtCore import QStandardPaths, QCoreApplication, Qt
from PyQt5.QtGui import QColor
from qutebrowser.utils import utils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import utils, qtutils
from qutebrowser.test import helpers

View File

@ -17,13 +17,13 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Tests for qutebrowser.utils.qt."""
"""Tests for qutebrowser.utils.qtutils."""
import sys
import argparse
import unittest
from qutebrowser.utils import qt
from qutebrowser.utils import qtutils
class CheckOverflowTests(unittest.TestCase):
@ -63,7 +63,7 @@ class CheckOverflowTests(unittest.TestCase):
for ctype, vals in self.GOOD_VALUES.items():
for val in vals:
with self.subTest(ctype=ctype, val=val):
qt.check_overflow(val, ctype)
qtutils.check_overflow(val, ctype)
def test_bad_values_fatal(self):
"""Test values which are outside bounds with fatal=True."""
@ -71,14 +71,14 @@ class CheckOverflowTests(unittest.TestCase):
for (val, _) in vals:
with self.subTest(ctype=ctype, val=val):
with self.assertRaises(OverflowError):
qt.check_overflow(val, ctype)
qtutils.check_overflow(val, ctype)
def test_bad_values_nonfatal(self):
"""Test values which are outside bounds with fatal=False."""
for ctype, vals in self.BAD_VALUES.items():
for (val, replacement) in vals:
with self.subTest(ctype=ctype, val=val):
newval = qt.check_overflow(val, ctype, fatal=False)
newval = qtutils.check_overflow(val, ctype, fatal=False)
self.assertEqual(newval, replacement)
@ -109,26 +109,26 @@ class GetQtArgsTests(unittest.TestCase):
def test_no_qt_args(self):
"""Test commandline with no Qt arguments given."""
ns = self._namespace(['--foo'], flags=['--foo'])
self.assertEqual(qt.get_args(ns), [sys.argv[0]])
self.assertEqual(qtutils.get_args(ns), [sys.argv[0]])
def test_qt_flag(self):
"""Test commandline with a Qt flag."""
ns = self._namespace(['--foo', '--qt-reverse', '--bar'],
flags=['--foo', '--qt-reverse', '--bar'])
self.assertEqual(qt.get_args(ns), [sys.argv[0], '-reverse'])
self.assertEqual(qtutils.get_args(ns), [sys.argv[0], '-reverse'])
def test_qt_arg(self):
"""Test commandline with a Qt argument."""
ns = self._namespace(['--qt-stylesheet', 'foobar'],
args=['--qt-stylesheet'])
self.assertEqual(qt.get_args(ns), [sys.argv[0], '-stylesheet',
'foobar'])
self.assertEqual(qtutils.get_args(ns), [sys.argv[0], '-stylesheet',
'foobar'])
def test_qt_both(self):
"""Test commandline with a Qt argument and flag."""
ns = self._namespace(['--qt-stylesheet', 'foobar', '--qt-reverse'],
flags=['--qt-reverse'], args=['--qt-stylesheet'])
qt_args = qt.get_args(ns)
qt_args = qtutils.get_args(ns)
self.assertEqual(qt_args[0], sys.argv[0])
self.assertIn('-reverse', qt_args)
self.assertIn('-stylesheet', qt_args)

View File

@ -205,7 +205,7 @@ def check_qt_version():
"""Check if the Qt version is recent enough."""
import operator
from PyQt5.QtCore import qVersion
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import qtutils
if qtutils.version_check('5.2.0', operator.lt):
text = ("Fatal error: Qt and PyQt >= 5.2.0 are required, but {} is "
"installed.".format(qVersion()))

View File

@ -27,8 +27,7 @@ from PyQt5.QtCore import QUrl
from PyQt5.QtNetwork import QHostInfo
from qutebrowser.config import config
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import log
from qutebrowser.utils import log, qtutils
# FIXME: we probably could raise some exceptions on invalid URLs

View File

@ -29,8 +29,7 @@ import enum as pyenum
from PyQt5.QtCore import pyqtSignal, QObject, QTimer
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import log
from qutebrowser.utils import log, qtutils
_UNSET = object()

View File

@ -35,7 +35,7 @@ from PyQt5.QtGui import QKeySequence, QColor
import pkg_resources
import qutebrowser
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import qtutils
def elide(text, length):

View File

@ -29,8 +29,7 @@ from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QItemSelectionModel
from qutebrowser.commands import utils as cmdutils
from qutebrowser.config import config, style
from qutebrowser.widgets import completiondelegate
from qutebrowser.utils import completer, usertypes
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import completer, usertypes, qtutils
class CompletionView(QTreeView):

View File

@ -30,7 +30,7 @@ from PyQt5.QtGui import (QIcon, QPalette, QTextDocument, QTextOption,
from qutebrowser.config import config, style
from qutebrowser.models import basecompletion
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import qtutils
class CompletionItemDelegate(QStyledItemDelegate):

View File

@ -24,7 +24,7 @@ from PyQt5.QtWidgets import QListView, QSizePolicy, QMenu
from qutebrowser.models import downloadmodel
from qutebrowser.config import style
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import qtutils
class DownloadView(QListView):

View File

@ -27,8 +27,7 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout
from qutebrowser.commands import utils as cmdutils
from qutebrowser.config import config
from qutebrowser.utils import message, log, usertypes
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import message, log, usertypes, qtutils
from qutebrowser.widgets import tabbedbrowser, completion, downloads
from qutebrowser.widgets.statusbar import bar

View File

@ -26,8 +26,7 @@ from PyQt5.QtWidgets import QLineEdit
from qutebrowser.keyinput import modeman
from qutebrowser.commands import utils as cmdutils
from qutebrowser.utils import usertypes, log
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import usertypes, log, qtutils
PromptContext = collections.namedtuple('PromptContext',

View File

@ -23,7 +23,7 @@ from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QLabel, QSizePolicy
from PyQt5.QtGui import QPainter
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import qtutils
class TextBase(QLabel):

View File

@ -32,8 +32,7 @@ from qutebrowser.commands import exceptions as cmdexc
from qutebrowser.keyinput import modeman
from qutebrowser.widgets import tabwidget, webview
from qutebrowser.browser import signalfilter, commands
from qutebrowser.utils import log, message, usertypes, utils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import log, message, usertypes, utils, qtutils
class TabbedBrowser(tabwidget.TabWidget):

View File

@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
QApplication)
from PyQt5.QtGui import QIcon, QPalette, QColor
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import qtutils
from qutebrowser.config import config

View File

@ -26,8 +26,7 @@ from PyQt5.QtWebKitWidgets import QWebView, QWebPage
from qutebrowser.config import config
from qutebrowser.keyinput import modeman
from qutebrowser.utils import message, webelem, log, usertypes, utils
from qutebrowser.utils import qt as qtutils
from qutebrowser.utils import message, webelem, log, usertypes, utils, qtutils
from qutebrowser.browser import webpage, hints
from qutebrowser.commands import exceptions as cmdexc