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