Rename {Command,Seach}Parser to *Manager
This commit is contained in:
parent
937196e287
commit
d4b35b6734
1
TODO
1
TODO
@ -18,7 +18,6 @@ Refactor completion widget mess (initializing / changing completions)
|
||||
we probably could replace CompletionModel with QStandardModel...
|
||||
replace foo_bar options with foo-bar
|
||||
reorder options
|
||||
rename *Parser to more meaningful names
|
||||
_foo = QApplication.instance().obj.foo for global singletons?
|
||||
decorators for often-used signals from singletons?
|
||||
- @on_config_changed('colors')
|
||||
|
@ -59,7 +59,7 @@ from qutebrowser.widgets.crash import CrashDialog
|
||||
from qutebrowser.keyinput.normalmode import NormalKeyParser
|
||||
from qutebrowser.keyinput.keyparser import PassthroughKeyParser
|
||||
from qutebrowser.keyinput.hintmode import HintKeyParser
|
||||
from qutebrowser.commands.parsers import CommandParser, SearchParser
|
||||
from qutebrowser.commands.managers import CommandManager, SearchManager
|
||||
from qutebrowser.utils.appdirs import AppDirs
|
||||
from qutebrowser.utils.misc import dotted_getattr
|
||||
from qutebrowser.utils.debug import set_trace # pylint: disable=unused-import
|
||||
@ -76,8 +76,8 @@ class QuteBrowser(QApplication):
|
||||
|
||||
Attributes:
|
||||
mainwindow: The MainWindow QWidget.
|
||||
commandparser: The main CommandParser instance.
|
||||
searchparser: The main SearchParser instance.
|
||||
commandmanager: The main CommandManager instance.
|
||||
searchmanager: The main SearchManager instance.
|
||||
_keyparsers: A mapping from modes to keyparsers.
|
||||
_dirs: AppDirs instance for config/cache directories.
|
||||
_args: ArgumentParser instance.
|
||||
@ -121,8 +121,8 @@ class QuteBrowser(QApplication):
|
||||
self.config = config.instance
|
||||
websettings.init()
|
||||
|
||||
self.commandparser = CommandParser()
|
||||
self.searchparser = SearchParser()
|
||||
self.commandmanager = CommandManager()
|
||||
self.searchmanager = SearchManager()
|
||||
self._keyparsers = {
|
||||
'normal': NormalKeyParser(self),
|
||||
'hint': HintKeyParser(self),
|
||||
@ -224,7 +224,7 @@ class QuteBrowser(QApplication):
|
||||
for e in self._args.command:
|
||||
if e.startswith(':'):
|
||||
logging.debug('Startup cmd {}'.format(e))
|
||||
self.commandparser.run(e.lstrip(':'))
|
||||
self.commandmanager.run(e.lstrip(':'))
|
||||
else:
|
||||
logging.debug('Startup url {}'.format(e))
|
||||
self._opened_urls.append(e)
|
||||
@ -269,11 +269,11 @@ class QuteBrowser(QApplication):
|
||||
modes.manager.key_pressed.connect(status.on_key_pressed)
|
||||
|
||||
# commands
|
||||
cmd.got_cmd.connect(self.commandparser.run)
|
||||
cmd.got_search.connect(self.searchparser.search)
|
||||
cmd.got_search_rev.connect(self.searchparser.search_rev)
|
||||
cmd.got_cmd.connect(self.commandmanager.run)
|
||||
cmd.got_search.connect(self.searchmanager.search)
|
||||
cmd.got_search_rev.connect(self.searchmanager.search_rev)
|
||||
cmd.returnPressed.connect(tabs.setFocus)
|
||||
self.searchparser.do_search.connect(tabs.cur.search)
|
||||
self.searchmanager.do_search.connect(tabs.cur.search)
|
||||
kp["normal"].keystring_updated.connect(status.keystring.setText)
|
||||
|
||||
# hints
|
||||
|
@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Module containing commandline parsers ( SearchParser and CommandParser)."""
|
||||
"""Module containing command managers (SearchManager and CommandManager)."""
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
@ -36,9 +36,9 @@ def split_cmdline(text):
|
||||
Return:
|
||||
A list of strings.
|
||||
"""
|
||||
parser = CommandParser()
|
||||
manager = CommandManager()
|
||||
try:
|
||||
parts = parser.parse(text)
|
||||
parts = manager.parse(text)
|
||||
except NoSuchCommandError:
|
||||
parts = text.split(' ')
|
||||
if text.endswith(' '):
|
||||
@ -46,9 +46,9 @@ def split_cmdline(text):
|
||||
return parts
|
||||
|
||||
|
||||
class SearchParser(QObject):
|
||||
class SearchManager(QObject):
|
||||
|
||||
"""Parse qutebrowser searches.
|
||||
"""Manage qutebrowser searches.
|
||||
|
||||
Attributes:
|
||||
_text: The text from the last search.
|
||||
@ -107,7 +107,7 @@ class SearchParser(QObject):
|
||||
"""
|
||||
self._search(text, rev=True)
|
||||
|
||||
@cmdutils.register(instance='searchparser', hide=True)
|
||||
@cmdutils.register(instance='searchmanager', hide=True)
|
||||
def nextsearch(self, count=1):
|
||||
"""Continue the search to the ([count]th) next term.
|
||||
|
||||
@ -122,9 +122,9 @@ class SearchParser(QObject):
|
||||
self.do_search.emit(self._text, self._flags)
|
||||
|
||||
|
||||
class CommandParser:
|
||||
class CommandManager:
|
||||
|
||||
"""Parse qutebrowser commandline commands.
|
||||
"""Manage qutebrowser commandline commands.
|
||||
|
||||
Attributes:
|
||||
_cmd: The command which was parsed.
|
@ -26,8 +26,8 @@ from PyQt5.QtGui import QKeySequence
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.utils.message as message
|
||||
from qutebrowser.commands.parsers import (CommandParser, ArgumentCountError,
|
||||
NoSuchCommandError)
|
||||
from qutebrowser.commands.managers import (CommandManager, ArgumentCountError,
|
||||
NoSuchCommandError)
|
||||
|
||||
|
||||
class KeyParser(QObject):
|
||||
@ -353,13 +353,13 @@ class CommandKeyParser(KeyParser):
|
||||
"""KeyChainParser for command bindings.
|
||||
|
||||
Attributes:
|
||||
commandparser: Commandparser instance.
|
||||
commandmanager: CommandManager instance.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None, supports_count=None,
|
||||
supports_chains=False):
|
||||
super().__init__(parent, supports_count, supports_chains)
|
||||
self.commandparser = CommandParser()
|
||||
self.commandmanager = CommandManager()
|
||||
|
||||
def _run_or_fill(self, cmdstr, count=None, ignore_exc=True):
|
||||
"""Run the command in cmdstr or fill the statusbar if args missing.
|
||||
@ -370,7 +370,7 @@ class CommandKeyParser(KeyParser):
|
||||
ignore_exc: Ignore exceptions.
|
||||
"""
|
||||
try:
|
||||
self.commandparser.run(cmdstr, count=count, ignore_exc=ignore_exc)
|
||||
self.commandmanager.run(cmdstr, count=count, ignore_exc=ignore_exc)
|
||||
except NoSuchCommandError:
|
||||
pass
|
||||
except ArgumentCountError:
|
||||
|
@ -36,7 +36,7 @@ import qutebrowser.commands.utils as cmdutils
|
||||
import qutebrowser.config.configdata as configdata
|
||||
from qutebrowser.models.completion import ROLE_MARKS, NoCompletionsError
|
||||
from qutebrowser.config.style import set_register_stylesheet, get_stylesheet
|
||||
from qutebrowser.commands.parsers import split_cmdline
|
||||
from qutebrowser.commands.managers import split_cmdline
|
||||
from qutebrowser.models.completionfilter import CompletionFilterModel
|
||||
from qutebrowser.models.commandcompletion import CommandCompletionModel
|
||||
from qutebrowser.models.settingcompletion import (
|
||||
|
@ -27,7 +27,7 @@ import qutebrowser.commands.utils as cmdutils
|
||||
from qutebrowser.keyinput.normalmode import STARTCHARS
|
||||
from qutebrowser.config.style import set_register_stylesheet, get_stylesheet
|
||||
from qutebrowser.utils.url import urlstring
|
||||
from qutebrowser.commands.parsers import split_cmdline
|
||||
from qutebrowser.commands.managers import split_cmdline
|
||||
from qutebrowser.models.cmdhistory import (History, HistoryEmptyError,
|
||||
HistoryEndReachedError)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user