parent
d04534dc33
commit
671ce67be5
@ -168,6 +168,8 @@ Removed
|
||||
thus removed.
|
||||
- All `--qt-*` arguments got replaced by `--qt-arg` and `--qt-flag` and thus
|
||||
removed.
|
||||
- The `-c`/`--confdir`, `--datadir` and `--cachedir` arguments got removed, as
|
||||
`--basedir` should be sufficient.
|
||||
|
||||
Fixed
|
||||
~~~~~
|
||||
|
@ -38,17 +38,8 @@ show it.
|
||||
*-h*, *--help*::
|
||||
show this help message and exit
|
||||
|
||||
*-c* 'CONFDIR', *--confdir* 'CONFDIR'::
|
||||
Set config directory
|
||||
|
||||
*--datadir* 'DATADIR'::
|
||||
Set data directory
|
||||
|
||||
*--cachedir* 'CACHEDIR'::
|
||||
Set cache directory
|
||||
|
||||
*--basedir* 'BASEDIR'::
|
||||
Base directory for all storage. Other --*dir arguments are ignored if this is given.
|
||||
Base directory for all storage.
|
||||
|
||||
*-V*, *--version*::
|
||||
Show version and quit.
|
||||
|
@ -320,8 +320,8 @@ def _open_quickstart(args):
|
||||
Args:
|
||||
args: The argparse namespace.
|
||||
"""
|
||||
if args.datadir is not None or args.basedir is not None:
|
||||
# With --datadir or --basedir given, don't open quickstart.
|
||||
if args.basedir is not None:
|
||||
# With --basedir given, don't open quickstart.
|
||||
return
|
||||
state_config = objreg.get('state-config')
|
||||
try:
|
||||
|
@ -47,13 +47,7 @@ def get_argparser():
|
||||
"""Get the argparse parser."""
|
||||
parser = argparse.ArgumentParser(prog='qutebrowser',
|
||||
description=qutebrowser.__description__)
|
||||
parser.add_argument('-c', '--confdir', help="Set config directory",
|
||||
type=directory)
|
||||
parser.add_argument('--datadir', help="Set data directory", type=directory)
|
||||
parser.add_argument('--cachedir', help="Set cache directory",
|
||||
type=directory)
|
||||
parser.add_argument('--basedir', help="Base directory for all storage. "
|
||||
"Other --*dir arguments are ignored if this is given.")
|
||||
parser.add_argument('--basedir', help="Base directory for all storage.")
|
||||
parser.add_argument('-V', '--version', help="Show version and quit.",
|
||||
action='store_true')
|
||||
parser.add_argument('-s', '--set', help="Set a temporary setting for "
|
||||
|
@ -145,11 +145,6 @@ def _from_args(typ, args):
|
||||
override: boolean, if the user did override the path
|
||||
path: The overridden path, or None to turn off storage.
|
||||
"""
|
||||
typ_to_argparse_arg = {
|
||||
QStandardPaths.ConfigLocation: 'confdir',
|
||||
QStandardPaths.DataLocation: 'datadir',
|
||||
QStandardPaths.CacheLocation: 'cachedir',
|
||||
}
|
||||
basedir_suffix = {
|
||||
QStandardPaths.ConfigLocation: 'config',
|
||||
QStandardPaths.DataLocation: 'data',
|
||||
@ -170,18 +165,6 @@ def _from_args(typ, args):
|
||||
return (False, None)
|
||||
return (True, os.path.abspath(os.path.join(basedir, suffix)))
|
||||
|
||||
try:
|
||||
argname = typ_to_argparse_arg[typ]
|
||||
except KeyError:
|
||||
return (False, None)
|
||||
arg_value = getattr(args, argname)
|
||||
|
||||
assert arg_value != '', argname
|
||||
if arg_value is None:
|
||||
return (False, None)
|
||||
else:
|
||||
return (True, arg_value)
|
||||
|
||||
|
||||
def _create(path):
|
||||
"""Create the `path` directory.
|
||||
|
@ -163,54 +163,7 @@ DirArgTest = collections.namedtuple('DirArgTest', 'arg, expected')
|
||||
@pytest.mark.usefixtures('reset_standarddir')
|
||||
class TestArguments:
|
||||
|
||||
"""Tests with confdir/cachedir/datadir arguments."""
|
||||
|
||||
@pytest.fixture(params=[DirArgTest('foo', 'foo')])
|
||||
def testcase(self, request, tmpdir):
|
||||
"""Fixture providing testcases."""
|
||||
# prepend tmpdir to both
|
||||
arg = str(tmpdir / request.param.arg)
|
||||
return DirArgTest(arg, arg)
|
||||
|
||||
def test_confdir(self, testcase):
|
||||
"""Test --confdir."""
|
||||
args = types.SimpleNamespace(confdir=testcase.arg, cachedir=None,
|
||||
datadir=None, basedir=None)
|
||||
standarddir.init(args)
|
||||
assert standarddir.config() == testcase.expected
|
||||
|
||||
def test_cachedir(self, testcase):
|
||||
"""Test --cachedir."""
|
||||
args = types.SimpleNamespace(confdir=None, cachedir=testcase.arg,
|
||||
datadir=None, basedir=None)
|
||||
standarddir.init(args)
|
||||
assert standarddir.cache() == testcase.expected
|
||||
|
||||
def test_datadir(self, testcase):
|
||||
"""Test --datadir."""
|
||||
args = types.SimpleNamespace(confdir=None, cachedir=None,
|
||||
datadir=testcase.arg, basedir=None)
|
||||
standarddir.init(args)
|
||||
assert standarddir.data() == testcase.expected
|
||||
|
||||
def test_confdir_none(self, mocker):
|
||||
"""Test --confdir with None given."""
|
||||
# patch makedirs to a noop so we don't really create a directory
|
||||
mocker.patch('qutebrowser.utils.standarddir.os.makedirs')
|
||||
args = types.SimpleNamespace(confdir=None, cachedir=None, datadir=None,
|
||||
basedir=None)
|
||||
standarddir.init(args)
|
||||
assert standarddir.config().split(os.sep)[-1] == 'qute_test'
|
||||
|
||||
def test_runtimedir(self, tmpdir, monkeypatch):
|
||||
"""Test runtime dir (which has no args)."""
|
||||
monkeypatch.setattr(
|
||||
'qutebrowser.utils.standarddir.QStandardPaths.writableLocation',
|
||||
lambda _typ: str(tmpdir))
|
||||
args = types.SimpleNamespace(confdir=None, cachedir=None,
|
||||
datadir=None, basedir=None)
|
||||
standarddir.init(args)
|
||||
assert standarddir.runtime() == str(tmpdir / 'qute_test')
|
||||
"""Tests the --basedir argument."""
|
||||
|
||||
@pytest.mark.parametrize('typ', ['config', 'data', 'cache', 'download',
|
||||
pytest.mark.linux('runtime')])
|
||||
|
Loading…
Reference in New Issue
Block a user