Florian Bruhin
284d4e4b97
Only pass is_bool to Command._param_to_argparse_*
2016-05-18 06:55:27 +02:00
Florian Bruhin
a83bf9c3ee
Simplify argparser.type_conv
...
Since we're not using those functions as argparse callbacks anymore, we
can write a normal function instead of factories, which simplifies
things a lot.
2016-05-18 06:55:27 +02:00
Florian Bruhin
6ed9b6b13f
Make sure typing.Union[str, int] gets handled
...
str always needs to be the last element checked as otherwise it'd always
win.
2016-05-18 06:55:17 +02:00
Florian Bruhin
a0d0b6464f
Use typing.py-like annotations for command args
...
This means:
- An annotation like (int, str) is now typing.Union[int, str].
- utils.typing got expanded so it acts like the real typing.py, with
issubclass() working properly with typing.Union and __union_params__
being set.
- A literal string doesn't exist anymore as annotation, instead
@cmdutils.argument now has a 'choices' argument which can be used like
@cmdutils.argument('arg', choices=['val1', 'val2']).
- Argument validating/converting is now entirely handled by
argparser.type_conv instead of relying on python's argparse, i.e.
type/choices is now not passed to argparse anymore.
2016-05-18 06:55:17 +02:00
Florian Bruhin
c33f0c3512
Use @cmdutils.argument for completions
2016-05-18 06:55:17 +02:00
Florian Bruhin
3ab40bbc23
Clear globals correctly for all cmdutils tests
...
TestArgument didn't clear the globals as the fixture was inside
TestRegister.
This means test_run_vulture failed in funny ways because run_vulture.py
generated a whitelist containing "<locals>" for commands:
tests/unit/scripts/test_run_vulture.py:55: in run
return run_vulture.run([str(e.basename) for e in files])
scripts/dev/run_vulture.py:146: in run
vult.scavenge(files + [whitelist_file.name])
.tox/py35/lib/python3.5/site-packages/vulture.py:107: in scavenge
self.scan(module_string)
.tox/py35/lib/python3.5/site-packages/vulture.py:75: in scan
node = ast.parse(node_string, filename=self.file)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
source = 'qutebrowser.browser.commands.CommandDispatcher.buffer\nqutebrowser.misc.savemanager.SaveManager.save_command\nqutebro...iidoc.UsageFormatter._get_default_metavar_for_positional\nscripts.dev.src2asciidoc.UsageFormatter._metavar_formatter\n'
filename = '/tmp/tmp_ein2umn', mode = 'exec'
def parse(source, filename='<unknown>', mode='exec'):
"""
Parse the source into an AST node.
Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
"""
> return compile(source, filename, mode, PyCF_ONLY_AST)
E File "/tmp/tmp_ein2umn", line 16
E test_cmdutils.TestArgument.test_wrong_order.<locals>.fun
E ^
E SyntaxError: invalid syntax
2016-05-18 06:55:17 +02:00
Florian Bruhin
1611562271
Get rid of dict annotations
2016-05-18 06:55:17 +02:00
Florian Bruhin
d990032a2e
Remove leftovers of 'name' annotation key
2016-05-18 06:55:17 +02:00
Florian Bruhin
77151d394a
Use @cmdutils.argument for metavar
2016-05-18 06:55:17 +02:00
Florian Bruhin
c14db202d6
Use @cmdutils.argument to hide arguments
2016-05-18 06:55:17 +02:00
Florian Bruhin
2fc4f408cd
Fix src2asciidoc
2016-05-18 06:55:17 +02:00
Florian Bruhin
2370793f38
Make win_id/count mutually exclusive for ArgInfo
2016-05-18 06:55:17 +02:00
Florian Bruhin
35135c4b0d
Use @cmdutils.argument for win_id/count
2016-05-18 06:55:17 +02:00
Florian Bruhin
04367851c3
Refactor how cmdutils.ArgInfo works
...
It's now a real class, and some other aspects about how it's handled
were cleaned up as well.
2016-05-18 06:55:17 +02:00
Florian Bruhin
9eeaeb95c3
Make sure @cmdutils.argument after @register fails
2016-05-18 06:55:17 +02:00
Florian Bruhin
3c586f34ff
Add a @cmdutils.argument decorator
...
For now the only available keyword argument is 'flag' which customizes
the flag an argument will get.
See #637 .
2016-05-18 06:55:17 +02:00
Florian Bruhin
4a551a6758
Show exception stack when handling cmdexc errors.
2016-05-13 07:43:44 +02:00
Florian Bruhin
5eff35ba30
cmdutils.register: annotation -> arg for flags
...
Instead of using a 'flag' key in the annotation dict, we now use a flags
argument to @cmdutils.register which is a {argument: flag} dict.
See #637 .
2016-05-10 07:35:41 +02:00
Florian Bruhin
73fbfb9731
Replace 'nargs' annotation by star_args_optional
...
Before we used a {'nargs': '*'} annotation for the respective argument
to tell qutebrowser it's optional for the commandline. Now we instead
use a star_args_optional argument for @cmdutils.register as a first step
towards freeing up argument annotations for PEP 484.
See #637 .
2016-05-09 22:49:24 +02:00
Florian Bruhin
e5630e9518
Fix lint
2016-05-01 23:03:27 +02:00
Florian Bruhin
3eeacd7e09
Fix userscripts on Windows
...
If the process emitted error() and then finished(), we already set
self._filepath to None and did other cleanup.
Instead we do the file reading inside _cleanup and call that from
on_process_error and on_process_finished.
2016-05-01 22:47:03 +02:00
Florian Bruhin
0b24916fc7
Add missing attribute
2016-05-01 22:34:04 +02:00
Florian Bruhin
4e333d61cd
Clean up failed userscripts correctly
2016-05-01 22:13:52 +02:00
adam
5eea9d0605
Cleanup for flake8/pylint
2016-04-28 09:20:16 -04:00
adam
8fd371d836
Proposed addition for issue #1386
2016-04-27 16:47:36 -04:00
Florian Bruhin
2a343cb3a1
Various code style improvements
2016-04-27 20:25:27 +02:00
Florian Bruhin
37b5f49c85
Fix types in @pyqtSlot decorations
...
PyQt 5.5 enforces correct type signatures, and there were a lot of
places where we were simply wrong, causing qutebrowser to not start at
all...
2016-04-26 20:34:38 +02:00
Panagiotis Ktistakis
c7534bd4a3
Allow {url:pretty} variable in commands
2016-04-19 16:37:05 +03:00
Florian Bruhin
642dc46ba9
flake8: Add hacking
2016-04-08 07:35:53 +02:00
Clayton Craft
439d815601
Now runner calls cmd_path instead of cmd
2016-03-24 16:26:19 -07:00
Clayton Craft
ff4e17190f
Allow searching system-wide data path on Linux for userscripts
2016-03-24 13:22:00 -07:00
Florian Bruhin
a5f2ac5f03
Adjust copyright years.
2016-01-04 07:12:39 +01:00
Florian Bruhin
8fdbd94d71
userscripts: Remove on_proc_error.
...
When there was an error, the finished signal will be emitted too anyways, so if
we call cleanup here, we'll call it twice which means we'll get an exception.
Supersedes #1175 .
2015-12-21 08:45:46 +01:00
Florian Bruhin
59c8e5c3d1
Add some tests for commands.userscripts.
2015-12-21 08:45:46 +01:00
Florian Bruhin
b8727d338f
Fix DummyUserscriptRunner.
2015-12-20 20:04:00 +01:00
Florian Bruhin
f787f004af
Fix _BaseUserscriptRunner when env is None.
2015-12-18 20:23:39 +01:00
Florian Bruhin
430b133c41
userscripts: Add docs for _QtFIFOReader attributes.
2015-12-13 13:11:06 +01:00
Florian Bruhin
494d48aac1
userscripts: Make fifo private in _QtFIFOReader.
2015-12-12 00:33:50 +01:00
Florian Bruhin
3a2d031479
userscripts: Move closing of fifo to _QtFIFOReader.
2015-12-12 00:33:25 +01:00
Florian Bruhin
eff0e4c7cc
pylint: Enable useless-suppression globally.
...
We deactivate it locally where needed, i.e. where we are sure it's some
platform-specific thing.
2015-12-01 23:01:09 +01:00
Florian Bruhin
150a83d8f4
pylint: Remove unneeded supressions.
2015-12-01 22:03:58 +01:00
Florian Bruhin
a156d51844
Don't use for-else when returning.
2015-12-01 21:56:38 +01:00
Florian Bruhin
bbaab24ce8
Fix lint.
2015-11-16 20:24:27 +01:00
Florian Bruhin
eeab4d41ba
Make it possible to pass a count via command name.
...
This is only used for tests so far and not intended for general usage (and thus
undocumented).
2015-11-15 19:55:01 +01:00
Peter Michely
bfccb91e42
Changed code and docs according to comments
2015-10-08 10:13:47 +02:00
Peter Michely
10f4798559
Fixed whitespace errors
2015-10-08 01:10:44 +02:00
Peter Michely
6be5c65c36
Fixed issue #943 and changed the docs accordingly
2015-10-07 23:53:21 +02:00
Florian Bruhin
005753e83e
Remove some dead code.
...
See #973 .
2015-10-04 20:43:29 +02:00
Florian Bruhin
d229e90724
Fix some splelling mistakes.
2015-10-04 15:41:42 +02:00
Florian Bruhin
4891fe9457
Always expand ~ when starting scripts.
2015-08-27 20:30:41 +02:00
Florian Bruhin
ed70d636d0
argparser: Check for unknown types.
2015-08-20 07:09:09 +02:00
Florian Bruhin
506917882e
argparser: Style fixes.
2015-08-20 07:08:59 +02:00
Florian Bruhin
127514f719
Document cmdutils.aliases attribute.
2015-08-17 21:13:23 +02:00
Florian Bruhin
3bfd049a0a
Don't use inspect.getfullargspec().
...
It seems to be deprecated in Python 3.5.
2015-08-16 15:43:28 +02:00
Florian Bruhin
7b8490b6c0
Fix 'an user' spelling.
2015-06-29 17:49:19 +02:00
Florian Bruhin
f1ba14b496
Fix exception when using :set.
...
This is a regression introduced in 167faafff2
.
2015-06-13 13:26:29 +02:00
Florian Bruhin
167faafff2
Fix command parsing for arguments containing _.
2015-06-12 11:42:16 +02:00
Florian Bruhin
5828bbafe9
Add -v (not -q) to :spawn and make it work with -u.
2015-06-11 20:30:37 +02:00
Florian Bruhin
ad401e035f
Proxy QProcess signals.
2015-06-11 20:30:37 +02:00
Florian Bruhin
163bc2e12e
Add GUIProcess.
...
This aims to unify the code which spawns a process and then shows statusbar
notifications when it exited, etc.
2015-06-11 20:30:03 +02:00
Florian Bruhin
17bb9fc21c
Use QProcess instead of subprocess.
...
Closes #646 .
Fixes #688 .
2015-06-11 20:28:04 +02:00
Florian Bruhin
36803cba06
Switch from flake8 to pytest-{mccabe,flakes,pep8}.
2015-06-02 20:51:06 +02:00
Florian Bruhin
d8e58b5886
Fix some typos.
2015-06-01 22:45:40 +02:00
Florian Bruhin
cdde1d7dfc
command: Add support for custom metavar for docs.
2015-05-31 15:10:12 +02:00
Florian Bruhin
b1dd649278
Replace _ by - in command flag names.
...
See #698 .
2015-05-30 19:30:08 +02:00
Florian Bruhin
aaf09dc573
Add possibility to hide command args from docs.
2015-05-15 19:19:30 +02:00
Florian Bruhin
9ee74253e4
Remove name annotation for cmdutils.register.
...
See #637 .
2015-04-20 22:25:27 +02:00
Florian Bruhin
7439586334
Move special params to cmdutils.register decorator
...
See #637 .
2015-04-20 19:33:05 +02:00
Florian Bruhin
0195cb31bb
Don't set scope in cmdutils.register w/o instance.
2015-04-20 18:55:22 +02:00
Florian Bruhin
f93eef848c
Store QUTE_TEXT/QUTE_HTML in files for userscripts.
...
Fixes #644 .
2015-04-20 07:50:47 +02:00
Florian Bruhin
4436941d97
Clean up unused imports.
2015-04-17 08:00:56 +02:00
Florian Bruhin
ffd1e673b3
Get rid of SearchRunner.
...
A SearchRunner was per-mainwindow, which caused bugs when searching in a tab
and in another before clearing the search.
Instead we now split it between WebView/CommandDispatcher.
Fixes #638 .
2015-04-17 07:51:21 +02:00
Florian Bruhin
4e18e54803
Fix handling of flags with args with maxsplit #2 .
...
Fixes #614 .
We only added the long variant of the flag, but not the short one.
2015-04-13 21:12:14 +02:00
Florian Bruhin
501138d5a0
Fix splitting of flags with args with maxsplit.
...
See #614 .
flags_with_args was set on keyword-only arguments, but an argument (like
--force for :bind) can also be keyword-only *and* bool.
2015-04-13 21:07:58 +02:00
Florian Bruhin
e24b06cdf9
Refactor and fix split commands in CommandRunner.
...
- split() now returns a ParseResult namedtuple with (cmd, args, cmdline)
arguments instead of only returning cmdline and setting self._cmd/self._args.
- Handling of split commands (;;) is now done in a separate parse_all()
function instead of run() to make testing easier.
See #615 .
2015-04-13 07:38:25 +02:00
Florian Bruhin
b1c475c61d
Use **kwargs to simplify cmdutils.register.
2015-04-06 17:25:42 +02:00
Florian Bruhin
20f0ef7ccc
Ignore ;; for splitting with some commands.
...
Fixes #405 .
2015-04-06 17:00:52 +02:00
Florian Bruhin
0b26e295bc
Revert fixes for quotes/spaces in maxsplit cmds.
...
Revert "Fix maxsplit-splitting with empty args (""/'')."
This reverts commit 46396cce1e
.
Revert "Remove quotes with split=False commands."
This reverts commit 81bc5dae94
.
See #564 and #453 .
2015-04-03 19:00:16 +02:00
Florian Bruhin
4e0712622b
Clear search when :search without args is given.
...
Needed for #564 because :search "" won't work anymore.
2015-04-03 14:40:26 +02:00
Florian Bruhin
8ebac8d38c
Various spelling fixes.
2015-03-31 21:11:47 +02:00
Florian Bruhin
82322beb03
Fix pep257 issues.
2015-03-26 07:08:54 +01:00
Florian Bruhin
7a4a4a4a4e
Pass tab_id correctly with scope='tab' commands.
...
Fixes #563 .
2015-03-19 22:19:25 +01:00
Florian Bruhin
61a52f3b91
command: Check the completion/argument counts.
...
See #531 .
2015-03-05 06:20:55 +01:00
Florian Bruhin
fcbd69e209
Clean up standarddir handling #2 .
...
We already attempted this in c5a2039da4
, but
having the directories as module attributes means they'll be created on start
(rather than when they're actually used), and it'd also be impossible to change
them after init for some reason in the future.
To still have a nice short API, we simply change the attributes to functions.
2015-02-26 07:01:22 +01:00
Florian Bruhin
c5a2039da4
Refactor QStandardPaths handling.
2015-02-22 19:13:51 +01:00
Florian Bruhin
a32f1e6180
Make it possible to deprecate commands.
...
See #448 .
2015-01-15 22:29:00 +01:00
Florian Bruhin
46396cce1e
Fix maxsplit-splitting with empty args (""/'').
...
Fixes #453 .
2015-01-06 10:00:28 +01:00
Florian Bruhin
efe96462c9
Pass more useful information to userscripts.
...
Closes #379 .
2015-01-04 20:16:15 +01:00
Florian Bruhin
b8a04f5309
Don't raise CommandError in TabbedBrowser.current_url.
...
TabbedBrowser.current_url used to process the qtutils.QtValueError exception
and raise a cmdexc.CommandError based on it. While this was useful for some
callers, it made handling it in others weird, and it doesn't really belong
there - so now the caller handles this.
2015-01-04 20:13:25 +01:00
Florian Bruhin
04c8a17b2e
Merge branch 'userscript-runner'
2015-01-04 15:21:31 +01:00
Florian Bruhin
f64269c57a
Add qutebrowser- to FIFO name.
2015-01-04 14:53:00 +01:00
Florian Bruhin
b1b1cecdb7
Add some more logging
2015-01-04 14:51:50 +01:00
Florian Bruhin
ecc7f09f86
Use QSocketNotifier for userscripts.
2015-01-04 14:36:59 +01:00
Florian Bruhin
450d1ab70d
Update copyright years
2015-01-03 15:51:31 +01:00
Johannes Altmanninger
8b69f9b62c
Registered 'search' as command.
...
Fixes #421 .
2014-12-29 22:45:26 +01:00
Florian Bruhin
b703028411
Clean up and temporarily disable alias completion.
...
Fixes #358 .
2014-12-28 22:08:38 +01:00
Florian Bruhin
03ac8874ff
Rewrite keymode handling to use only one mode.
...
Fixes #417 .
Fixes #418 .
See 4ab5d2df28
.
2014-12-28 00:01:27 +01:00
Florian Bruhin
512d7c4448
Simplify config exception tree and handling.
...
Also make sure we catch all config-related errors in all related places.
Fixes #324 .
2014-12-17 11:17:18 +01:00
Florian Bruhin
efd632ea73
Preserve arguments when re-splitting with aliases.
...
Fixes #339 .
2014-12-15 23:06:42 +01:00
Florian Bruhin
06ec1a3885
Big file tree reorganisation.
...
Closes #255 .
Should make a lot more sense now ;)
2014-12-13 17:28:50 +01:00
Florian Bruhin
451df7bbf4
Handle flags with args correctly with split=False.
2014-12-11 21:17:43 +01:00
Florian Bruhin
b7ea8e7979
Support a maxsplit argument for commands.
2014-12-11 20:32:52 +01:00
Florian Bruhin
81bc5dae94
Remove quotes with split=False commands.
...
Fixes #313 .
2014-12-11 20:04:29 +01:00
Florian Bruhin
ec07e4f8be
Handle OSError exceptions where appropriate.
...
Fixes #25 .
2014-12-10 18:00:49 +01:00
Florian Bruhin
96c72724ce
Handle whitespace correctly when splitting with flags.
...
Fixes #248 .
2014-11-10 08:14:45 +01:00
Florian Bruhin
1b46c96192
Fix completion when deleting command
2014-11-10 07:59:39 +01:00
Florian Bruhin
4e9b9baeab
Split commands with split=False correctly.
...
Fixes #231 .
2014-11-09 20:46:21 +01:00
Florian Bruhin
5fe04a6aec
Make completion work more or less
2014-11-06 08:26:01 +01:00
Florian Bruhin
d730471fd7
Start using keep=True for commandline.
2014-11-06 07:15:02 +01:00
Florian Bruhin
3fa8efc34b
Initial shlex fork
2014-11-03 21:27:07 +01:00
Florian Bruhin
0f550f696c
Clean up Command.
2014-10-26 22:08:13 +01:00
Florian Bruhin
0b37ad4348
Don't pass unknown dict keys to argparse in function annotations.
2014-10-20 20:27:33 +02:00
Florian Bruhin
c7f6a747a8
Check flag length in function annotations.
2014-10-20 20:27:19 +02:00
Florian Bruhin
fd6e56d7af
Convert all function annotations to dicts.
2014-10-20 17:20:39 +02:00
Florian Bruhin
b54151f206
Use last focused window for download errors and other stuff.
...
When the event happens, it's possible we don't have any window focused yet, so
we display it in the window which was last focused.
Fixes #191 .
2014-10-15 20:42:40 +02:00
Florian Bruhin
bda3c9b1d0
Refactor Command._inspect_function.
2014-10-14 07:59:42 +02:00
Florian Bruhin
46b15a1f11
userscripts: Remove invalid encoding param to os.open.
...
Fixes #182 .
This was a regression introduced in 17dd4732ae
.
2014-10-13 15:09:23 +02:00
Florian Bruhin
1761d98c1b
Fix lint
2014-10-10 07:50:50 +02:00
Florian Bruhin
0e771db7f1
Use annotation instead of special argument names.
...
Explicit is better than implicit.
Fixes #161 .
2014-10-09 06:33:24 +02:00
Florian Bruhin
33043f0f6c
Fix lint
2014-10-08 22:20:38 +02:00
Florian Bruhin
d32a0c30c6
command: Remove unneeded has_count check.
2014-10-08 07:40:53 +02:00
Florian Bruhin
1a00d6168c
command: Check for handlers with count and no default.
2014-10-08 07:40:39 +02:00
Florian Bruhin
0e7a60abf6
Move utils.get_standard_dir to its own file.
...
This is a preparation for #19 and #20 because there are too many functions
related to standarddir in utils.
2014-10-08 06:20:31 +02:00
Florian Bruhin
6349a6a213
Remove Emit:/Raise: from docstrings.
...
They got out-of-sync fast and provided no real benefit.
2014-10-07 23:08:37 +02:00
Florian Bruhin
d8a917575d
Add a cmdutils.check_exclusive function.
2014-10-07 20:39:02 +02:00
Florian Bruhin
105c25bc5f
Merge branch 'multiwin'
...
Conflicts:
qutebrowser/app.py
qutebrowser/browser/commands.py
qutebrowser/browser/hints.py
qutebrowser/keyinput/modeman.py
qutebrowser/network/networkmanager.py
qutebrowser/widgets/mainwindow.py
qutebrowser/widgets/statusbar/command.py
qutebrowser/widgets/statusbar/prompt.py
qutebrowser/widgets/statusbar/prompter.py
qutebrowser/widgets/tabbedbrowser.py
2014-10-06 22:03:58 +02:00
Florian Bruhin
9281fa3992
Fix lint/bugs
2014-10-06 19:53:50 +02:00
Florian Bruhin
d674b90240
Clean up FIXMEs and add github URLs
2014-10-01 22:23:27 +02:00
Florian Bruhin
6aeecb3803
Fix lints/bugs
2014-09-29 20:36:53 +02:00
Florian Bruhin
106ad9f4ed
userscripts: Don't store a list of runners.
2014-09-29 20:16:54 +02:00
Florian Bruhin
865389bb34
Make CommandRunner a QObject.
2014-09-29 20:16:38 +02:00
Florian Bruhin
45ac2e4835
Fix getting URL for startup commands.
2014-09-29 19:56:37 +02:00
Florian Bruhin
714c9d8b01
Add win_id parameter to commands which need it.
2014-09-29 19:14:11 +02:00
Florian Bruhin
36f7ff6154
Fix some objreg.get calls.
2014-09-28 23:23:02 +02:00
Florian Bruhin
dc7b32e460
Fix lint
2014-09-28 22:23:37 +02:00
Florian Bruhin
fb6cb62f93
First attempt at multi-window support.
2014-09-28 22:13:14 +02:00
Florian Bruhin
65d1d21d2e
Always use a list for namedtuple.
2014-09-28 00:43:08 +02:00
Florian Bruhin
0fadf6b091
Use a list as items-argument for usertypes.enum
2014-09-28 00:42:53 +02:00
Florian Bruhin
36fd2e5c7f
Improve __repr__ methods.
2014-09-26 15:48:24 +02:00
Florian Bruhin
e527db1560
Add scope argument to cmdutils.register/commands.
2014-09-25 07:41:51 +02:00
Florian Bruhin
05ff908c4f
Update attributes in docstrings.
2014-09-24 22:25:11 +02:00
Florian Bruhin
62e55499eb
Privatize all attributes which aren't needed from the outside.
2014-09-24 22:25:11 +02:00
Florian Bruhin
3f02451828
Move object registry to its own file.
2014-09-24 07:06:45 +02:00
Florian Bruhin
2b60cdb64c
Object names cleanup
2014-09-23 23:05:55 +02:00
Florian Bruhin
297e37fdf2
Remove legacy instance= parameter support.
2014-09-23 22:08:05 +02:00
Florian Bruhin
a76c4c8ba5
Use object registry for tabbedbrowser.
2014-09-23 22:01:46 +02:00
Florian Bruhin
5f45d3de60
Use object registry for modeman.
2014-09-23 20:02:48 +02:00
Florian Bruhin
ab95234dad
Add object registry support to command handler.
2014-09-23 19:53:48 +02:00
Florian Bruhin
f4876c7f4f
Split docutils from utils
2014-09-23 04:22:51 +02:00
Florian Bruhin
9954a08ea2
Fix commands with ignore_args=True (e.g. :restart)
2014-09-22 22:46:03 +02:00