Use maxsplit (passed to str.split()) instead bool
This commit is contained in:
parent
4421862b3e
commit
b323706f5f
@ -336,7 +336,7 @@ class QuteBrowser(QApplication):
|
||||
logging.debug("maybe_quit quitting.")
|
||||
self.quit()
|
||||
|
||||
@cmdutils.register(instance='', split_args=False)
|
||||
@cmdutils.register(instance='', maxsplit=0)
|
||||
def pyeval(self, s):
|
||||
"""Evaluate a python string and display the results as a webpage.
|
||||
|
||||
|
@ -78,8 +78,7 @@ class CurCommandDispatcher(QObject):
|
||||
return
|
||||
frame.setScrollBarValue(orientation, int(m * perc / 100))
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cur', name='open',
|
||||
split_args=False)
|
||||
@cmdutils.register(instance='mainwindow.tabs.cur', name='open', maxsplit=0)
|
||||
def openurl(self, url, count=None):
|
||||
"""Open an url in the current/[count]th tab.
|
||||
|
||||
|
@ -30,7 +30,10 @@ class Command(QObject):
|
||||
|
||||
Attributes:
|
||||
name: The main name of the command.
|
||||
split_args: Whether to split the arguments or not.
|
||||
maxsplit: Maximum count of splits to be made.
|
||||
-1: Split everything (default)
|
||||
0: Don't split.
|
||||
n: Split a maximum of n times.
|
||||
hide: Whether to hide the arguments or not.
|
||||
nargs: A (minargs, maxargs) tuple, maxargs = None if there's no limit.
|
||||
count: Whether the command supports a count, or not.
|
||||
@ -51,11 +54,11 @@ class Command(QObject):
|
||||
|
||||
signal = pyqtSignal(tuple)
|
||||
|
||||
def __init__(self, name, split_args, hide, nargs, count, desc, instance,
|
||||
def __init__(self, name, maxsplit, hide, nargs, count, desc, instance,
|
||||
handler, completion):
|
||||
super().__init__()
|
||||
self.name = name
|
||||
self.split_args = split_args
|
||||
self.maxsplit = maxsplit
|
||||
self.hide = hide
|
||||
self.nargs = nargs
|
||||
self.count = count
|
||||
|
@ -146,10 +146,8 @@ class CommandParser:
|
||||
|
||||
if len(parts) == 1:
|
||||
args = []
|
||||
elif cmd.split_args:
|
||||
args = parts[1].split()
|
||||
else:
|
||||
args = [parts[1]]
|
||||
args = parts[1].split(maxsplit=cmd.maxsplit)
|
||||
self._cmd = cmd
|
||||
self._args = args
|
||||
return [cmdstr] + args
|
||||
|
@ -37,13 +37,16 @@ class register: # pylint: disable=invalid-name
|
||||
instance: The instance to be used as "self", as a dotted string.
|
||||
name: The name (as string) or names (as list) of the command.
|
||||
nargs: A (minargs, maxargs) tuple of valid argument counts, or an int.
|
||||
split_args: Whether to split the arguments or not.
|
||||
maxsplit: Maximum count of splits to be made.
|
||||
-1: Split everything (default)
|
||||
0: Don't split.
|
||||
n: Split a maximum of n times.
|
||||
hide: Whether to hide the command or not.
|
||||
completion: Which completion to use for arguments, as a list of
|
||||
strings.
|
||||
"""
|
||||
|
||||
def __init__(self, instance=None, name=None, nargs=None, split_args=True,
|
||||
def __init__(self, instance=None, name=None, nargs=None, maxsplit=-1,
|
||||
hide=False, completion=None):
|
||||
"""Save decorator arguments.
|
||||
|
||||
@ -53,7 +56,7 @@ class register: # pylint: disable=invalid-name
|
||||
See class attributes.
|
||||
"""
|
||||
self.name = name
|
||||
self.split_args = split_args
|
||||
self.maxsplit = maxsplit
|
||||
self.hide = hide
|
||||
self.nargs = nargs
|
||||
self.instance = instance
|
||||
@ -84,7 +87,7 @@ class register: # pylint: disable=invalid-name
|
||||
names += name
|
||||
count, nargs = self._get_nargs_count(func)
|
||||
desc = func.__doc__.splitlines()[0].strip().rstrip('.')
|
||||
cmd = Command(name=mainname, split_args=self.split_args,
|
||||
cmd = Command(name=mainname, maxsplit=self.maxsplit,
|
||||
hide=self.hide, nargs=nargs, count=count, desc=desc,
|
||||
instance=self.instance, handler=func,
|
||||
completion=self.completion)
|
||||
|
@ -210,7 +210,7 @@ class TabbedBrowser(TabWidget):
|
||||
elif last_close == 'blank':
|
||||
tab.openurl('about:blank')
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs', split_args=False)
|
||||
@cmdutils.register(instance='mainwindow.tabs', maxsplit=0)
|
||||
def tabopen(self, url):
|
||||
"""Open a new tab with a given url.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user