summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Schwab <git@nicholas-schwab.de>2021-04-08 17:49:03 +0200
committerNicholas Schwab <git@nicholas-schwab.de>2021-04-08 18:14:35 +0200
commit4bdbdea0946b78d92c3adbb43d03375d1aad63c9 (patch)
treeb2e10ec9266a53e315a9c8a36fa948d5003e11a7
parent353bb19cd5e69548f979421d6078f2ea85ad8451 (diff)
downloadqutebrowser-4bdbdea0946b78d92c3adbb43d03375d1aad63c9.tar.gz
qutebrowser-4bdbdea0946b78d92c3adbb43d03375d1aad63c9.zip
Revert all prefix-related commits.
This reverts commits 02a64630aa83e37e47a28a60366e1c65f0eba3ac to 4ff204aecc96d77209a18594a14da96af703c43f.
-rw-r--r--doc/help/settings.asciidoc9
-rw-r--r--qutebrowser/config/configdata.py4
-rw-r--r--qutebrowser/config/configdata.yml5
-rw-r--r--qutebrowser/config/configfiles.py23
-rw-r--r--qutebrowser/config/configtypes.py37
-rwxr-xr-xscripts/dev/src2asciidoc.py27
-rw-r--r--tests/unit/config/test_configtypes.py122
7 files changed, 23 insertions, 204 deletions
diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc
index 1d017790a..e747b0d75 100644
--- a/doc/help/settings.asciidoc
+++ b/doc/help/settings.asciidoc
@@ -3971,7 +3971,7 @@ Default: +pass:[always]+
=== statusbar.widgets
List of widgets displayed in the statusbar.
-Type: <<types,List of PrefixOrString>>
+Type: <<types,List of String>>
Valid values:
@@ -3983,10 +3983,6 @@ Valid values:
* +keypress+: Display pressed keys when composing a vi command.
* +progress+: Progress bar for the current page loading.
-Valid prefixes (separator is +:+):
-
- * +text+: A text widget. Add your own text as content.
-
Default:
- +pass:[keypress]+
@@ -4595,9 +4591,6 @@ When setting from a string, pass a json-like list, e.g. `["one", "two"]`.
|Perc|A percentage.
|PercOrInt|Percentage or integer.
|Position|The position of the tab bar.
-|PrefixOrString|A Widget for the status bar.
-
-Allows some predefined widgets and custom text-widgets via text:$CONTENT.
|Proxy|A proxy URL, or `system`/`none`.
|QssColor|A color value supporting gradients.
diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py
index 8e1be5509..ec4efc375 100644
--- a/qutebrowser/config/configdata.py
+++ b/qutebrowser/config/configdata.py
@@ -105,10 +105,6 @@ def _parse_yaml_type(
valid_values = kwargs.get('valid_values', None)
if valid_values is not None:
kwargs['valid_values'] = configtypes.ValidValues(*valid_values)
-
- valid_prefixes = kwargs.get('valid_prefixes', None)
- if valid_prefixes is not None:
- kwargs['valid_prefixes'] = configtypes.ValidPrefixes(*valid_prefixes)
else:
_raise_invalid_node(name, 'type', node)
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index 3e84f2e61..9ceb84173 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -1917,7 +1917,7 @@ statusbar.widgets:
type:
name: List
valtype:
- name: PrefixOrString
+ name: StatusbarWidget
valid_values:
- url: "Current page URL."
- scroll: "Percentage of the current page position like `10%`."
@@ -1927,8 +1927,7 @@ statusbar.widgets:
- tabs: "Current active tab, e.g. `2`."
- keypress: "Display pressed keys when composing a vi command."
- progress: "Progress bar for the current page loading."
- valid_prefixes:
- - text: "A text widget. Add your own text as content."
+ - text: "A text widget. Currently hard coded content."
none_ok: true
default: ['keypress', 'url', 'scroll', 'history', 'tabs', 'progress']
desc: List of widgets displayed in the statusbar.
diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py
index 78991b5ec..f8566e2d0 100644
--- a/qutebrowser/config/configfiles.py
+++ b/qutebrowser/config/configfiles.py
@@ -788,15 +788,6 @@ class ConfigPyWriter:
yield self._line("config.load_autoconfig(False)")
yield ''
- def _gen_valid_list(self, head: str, valid_list) -> Iterator[str]:
- yield self._line(head)
- for val in valid_list:
- try:
- desc = valid_list.descriptions[val]
- yield self._line("# - {}: {}".format(val, desc))
- except KeyError:
- yield self._line("# - {}".format(val))
-
def _gen_options(self) -> Iterator[str]:
"""Generate the options part of the config."""
for pattern, opt, value in self._options:
@@ -810,13 +801,13 @@ class ConfigPyWriter:
valid_values = opt.typ.get_valid_values()
if valid_values is not None and valid_values.generate_docs:
- yield from self._gen_valid_list('# Valid Values: \n', valid_values)
-
- valid_prefixes = opt.typ.get_valid_prefixes()
- if valid_prefixes is not None and valid_prefixes.generate_docs:
- yield from self._gen_valid_list(
- '# Valid Prefixes (separator is {}): \n'.format(
- valid_prefixes.separator), valid_prefixes)
+ yield self._line("# Valid values:")
+ for val in valid_values:
+ try:
+ desc = valid_values.descriptions[val]
+ yield self._line("# - {}: {}".format(val, desc))
+ except KeyError:
+ yield self._line("# - {}".format(val))
if pattern is None:
yield self._line('c.{} = {!r}'.format(opt.name, value))
diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py
index 55fc36e83..4439cd4f4 100644
--- a/qutebrowser/config/configtypes.py
+++ b/qutebrowser/config/configtypes.py
@@ -142,24 +142,6 @@ class ValidValues:
self.descriptions == other.descriptions)
-class ValidPrefixes(ValidValues):
-
- def __init__(self, *values, separator: str = ':', **kwargs):
- super().__init__(*values, **kwargs)
- self.separator = separator
-
- def __contains__(self, item) -> bool:
- return any(map(lambda x: item.startswith(x + self.separator), self.values))
-
- def __repr__(self) -> str:
- return utils.get_repr(self, values=self.values, separator=self.separator,
- descriptions=self.descriptions)
-
- def __eq__(self, other: object) -> bool:
- assert (isinstance(other, ValidPrefixes))
- return super().__eq__(other) and self.separator == other.separator
-
-
class BaseType:
"""A type used for a setting value.
@@ -181,7 +163,6 @@ class BaseType:
self._completions = completions
self.none_ok = none_ok
self.valid_values: Optional[ValidValues] = None
- self.valid_prefixes: Optional[ValidPrefixes] = None
def get_name(self) -> str:
"""Get a name for the type for documentation."""
@@ -191,10 +172,6 @@ class BaseType:
"""Get the type's valid values for documentation."""
return self.valid_values
- def get_valid_prefixes(self) -> Optional[ValidPrefixes]:
- """Get the type's valid prefixes for documentation."""
- return self.valid_prefixes
-
def _basic_py_validation(
self, value: Any,
pytype: Union[type, Tuple[type, ...]]) -> None:
@@ -532,9 +509,6 @@ class List(BaseType):
def get_valid_values(self) -> Optional[ValidValues]:
return self.valtype.get_valid_values()
- def get_valid_prefixes(self) -> Optional[ValidPrefixes]:
- return self.valtype.get_valid_prefixes()
-
def from_str(self, value: str) -> Optional[ListType]:
self._basic_str_validation(value)
if not value:
@@ -640,9 +614,6 @@ class ListOrValue(BaseType):
def get_valid_values(self) -> Optional[ValidValues]:
return self.valtype.get_valid_values()
- def get_valid_prefixes(self) -> Optional[ValidPrefixes]:
- return self.valtype.get_valid_prefixes()
-
def from_str(self, value: str) -> Any:
try:
return self.listtype.from_str(value)
@@ -2027,17 +1998,13 @@ class UrlPattern(BaseType):
raise configexc.ValidationError(value, str(e))
-class PrefixOrString(String):
+class StatusbarWidget(String):
"""A Widget for the status bar.
Allows some predefined widgets and custom text-widgets via text:$CONTENT."""
- def __init__(self, *, valid_prefixes: ValidPrefixes = None, **kwargs):
- super().__init__(**kwargs)
- self.valid_prefixes = valid_prefixes
-
def _validate_valid_values(self, value: str) -> None:
- if value in self.valid_prefixes:
+ if value.startswith("text:"):
return
super()._validate_valid_values(value)
diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py
index 6342a6180..82bbdb167 100755
--- a/scripts/dev/src2asciidoc.py
+++ b/scripts/dev/src2asciidoc.py
@@ -435,18 +435,6 @@ def _generate_setting_backend_info(f, opt):
.format(opt.backends))
-def _format_valid_list(f, head, valid_list):
- f.write(head)
- f.write("\n")
- for val in valid_list:
- try:
- desc = valid_list.descriptions[val]
- f.write(" * +{}+: {}".format(val, desc) + "\n")
- except KeyError:
- f.write(" * +{}+".format(val) + "\n")
- f.write("\n")
-
-
def _generate_setting_option(f, opt):
"""Generate documentation for a single section."""
f.write("\n")
@@ -467,12 +455,15 @@ def _generate_setting_option(f, opt):
valid_values = opt.typ.get_valid_values()
if valid_values is not None and valid_values.generate_docs:
- _format_valid_list(f, "Valid values:\n", valid_values)
-
- valid_prefixes = opt.typ.get_valid_prefixes()
- if valid_prefixes is not None and valid_prefixes.generate_docs:
- _format_valid_list(f, "Valid prefixes (separator is +{}+):\n".format(
- valid_prefixes.separator), valid_prefixes)
+ f.write("Valid values:\n")
+ f.write("\n")
+ for val in valid_values:
+ try:
+ desc = valid_values.descriptions[val]
+ f.write(" * +{}+: {}".format(val, desc) + "\n")
+ except KeyError:
+ f.write(" * +{}+".format(val) + "\n")
+ f.write("\n")
f.write("Default: {}\n".format(opt.typ.to_doc(opt.default)))
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index fd253e692..28c52a1e0 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -186,93 +186,6 @@ class TestValidValues:
assert vv.descriptions['bar'] == "bar desc"
-class TestValidPrefixes:
-
- @pytest.fixture
- def klass(self):
- return configtypes.ValidPrefixes
-
- @pytest.mark.parametrize('valid_values, separator, contained, not_contained', [
- # Without description
- (['foo', 'bar'], ':', ['foo:blub'], ['bar.blah', 'baz:blub', 'foo']),
- # With description
- ([('foo', "foo desc"), ('bar', "bar desc")], '/', ['foo/blub'],
- ['bar:blah', 'baz/blub', 'foo']),
- # With mixed description
- ([('foo', "foo desc"), 'bar'], '.', ['foo.blub'],
- ['bar:blah', 'baz.blub', 'foo']),
- ])
- def test_contains(self, klass, valid_values, separator, contained, not_contained):
- """Test __contains___ with various values."""
- vv = klass(*valid_values, separator=separator)
- for elem in contained:
- assert elem in vv
- for elem in not_contained:
- assert elem not in vv
-
- @pytest.mark.parametrize('valid_values', [
- # With description
- ['foo', 'bar'],
- [('foo', "foo desc"), ('bar', "bar desc")],
- [('foo', "foo desc"), 'bar'],
- ])
- def test_iter_without_desc(self, klass, valid_values):
- """Test __iter__ without a description."""
- vv = klass(*valid_values)
- assert list(vv) == ['foo:', 'bar:']
-
- def test_descriptions(self, klass):
- """Test descriptions."""
- vv = klass(
- ('one-with', "desc 1"),
- ('two-with', "desc 2"),
- 'three-without',
- ('four-without', None)
- )
- assert vv.descriptions['one-with'] == "desc 1"
- assert vv.descriptions['two-with'] == "desc 2"
- assert 'three-without' not in vv.descriptions
- assert 'four-without' not in vv.descriptions
-
- @pytest.mark.parametrize('args, separator, expected', [
- (['a', 'b'], ':', "<qutebrowser.config.configtypes.ValidPrefixes "
- "descriptions={} separator=':' values=['a', 'b']>"),
- ([('val', 'desc')], '/', "<qutebrowser.config.configtypes.ValidPrefixes "
- "descriptions={'val': 'desc'} separator='/' "
- "values=['val']>"),
- ])
- def test_repr(self, klass, args, separator, expected):
- assert repr(klass(*args, separator=separator)) == expected
-
- def test_empty(self, klass):
- with pytest.raises(ValueError):
- klass()
-
- @pytest.mark.parametrize('args1, args2, is_equal', [
- ((('foo', 'bar'), {}), (('foo', 'bar'), {}), True),
- ((('foo', 'bar'), {}), (('foo', 'baz'), {}), False),
- ((('foo', 'bar'), {'separator': '/'}), (('foo', 'bar'), {}), False),
- (((('foo', 'foo desc'), ('bar', 'bar desc')), {}),
- ((('foo', 'foo desc'), ('bar', 'bar desc')), {}),
- True),
- (((('foo', 'foo desc'), ('bar', 'bar desc')), {}),
- ((('foo', 'foo desc'), ('bar', 'bar desc2')), {}),
- False),
- ])
- def test_equal(self, klass, args1, args2, is_equal):
- obj1 = klass(*args1[0], **args1[1])
- obj2 = klass(*args2[0], **args2[1])
- assert (obj1 == obj2) == is_equal
-
- def test_from_dict(self, klass):
- """Test initializing from a list of dicts."""
- vv = klass({'foo': "foo desc"}, {'bar': "bar desc"})
- assert 'foo:blah' in vv
- assert 'bar:blub' in vv
- assert vv.descriptions['foo'] == "foo desc"
- assert vv.descriptions['bar'] == "bar desc"
-
-
class TestAll:
"""Various tests which apply to all available config types."""
@@ -483,11 +396,6 @@ class TestBaseType:
basetype.valid_values = configtypes.ValidValues('foo')
assert basetype.get_valid_values() is basetype.valid_values
- def test_get_valid_prefixes(self, klass):
- basetype = klass()
- basetype.valid_prefixes = configtypes.ValidPrefixes('foo')
- assert basetype.get_valid_prefixes() is basetype.valid_prefixes
-
@pytest.mark.parametrize('value, expected', [
('hello', '+pass:[hello]+'),
('', 'empty'),
@@ -633,14 +541,12 @@ class ListSubclass(configtypes.List):
"""
def __init__(self, none_ok_inner=False, none_ok_outer=False, length=None,
- elemtype=None, set_valid_values=False, set_valid_prefixes=False):
+ elemtype=None, set_valid_values=False):
if elemtype is None:
elemtype = configtypes.String(none_ok=none_ok_inner)
super().__init__(elemtype, none_ok=none_ok_outer, length=length)
if set_valid_values:
self.valtype.valid_values = configtypes.ValidValues('foo', 'bar', 'baz')
- if set_valid_prefixes:
- self.valtype.valid_prefixes = configtypes.ValidPrefixes('foo', 'bar', 'baz')
class FlagListSubclass(configtypes.FlagList):
@@ -653,15 +559,12 @@ class FlagListSubclass(configtypes.FlagList):
combinable_values = ['foo', 'bar']
def __init__(self, none_ok_inner=False, none_ok_outer=False, length=None,
- set_valid_values=False, set_valid_prefixes=False):
+ set_valid_values=False):
# none_ok_inner is ignored, just here for compatibility with TestList
super().__init__(none_ok=none_ok_outer, length=length)
if set_valid_values:
self.valtype.valid_values = configtypes.ValidValues(
'foo', 'bar', 'baz')
- if set_valid_prefixes:
- self.valtype.valid_prefixes = configtypes.ValidPrefixes(
- 'foo', 'bar', 'baz')
class FromObjType(configtypes.BaseType):
@@ -745,10 +648,6 @@ class TestList:
expected = configtypes.ValidValues('foo', 'bar', 'baz')
assert klass(set_valid_values=True).get_valid_values() == expected
- def test_get_valid_prefixes(self, klass):
- expected = configtypes.ValidPrefixes('foo', 'bar', 'baz')
- assert klass(set_valid_prefixes=True).get_valid_prefixes() == expected
-
def test_to_str(self, klass):
assert klass().to_str(["a", True]) == '["a", true]'
@@ -2218,23 +2117,6 @@ class TestUrlPattern:
klass().to_py('http://')
-class TestPrefixOrString:
-
- @pytest.fixture
- def klass(self):
- return configtypes.PrefixOrString
-
- def test_to_py_valid(self, klass):
- widget = klass()
- widget.valid_values = configtypes.ValidValues('foo')
- widget.valid_prefixes = configtypes.ValidPrefixes('bar')
-
- patterns = ['foo', 'bar:baz']
-
- for i in patterns:
- assert i == widget.to_py(i)
-
-
@pytest.mark.parametrize('first, second, equal', [
(re.compile('foo'), RegexEq('foo'), True),
(RegexEq('bar'), re.compile('bar'), True),