style changes

This commit is contained in:
Patric Schmitz 2015-11-27 00:03:04 +01:00
parent 6f65397dfe
commit c322130dc0
2 changed files with 31 additions and 19 deletions

View File

@ -242,7 +242,10 @@ def data(readonly=False):
"last loaded session."),
('url-incdec-segments',
SettingValue(typ.URLSegmentList(), 'path,query'),
SettingValue(
typ.FlagList(valid_values=typ.ValidValues(
'host', 'path', 'query', 'anchor')),
'path,query'),
"The URL segments where `:navigate increment/decrement` will "
"search for a number."),
@ -402,12 +405,12 @@ def data(readonly=False):
"Automatically open completion when typing."),
('download-path-suggestion',
SettingValue(typ.String(
valid_values=typ.ValidValues(
SettingValue(
typ.String(valid_values=typ.ValidValues(
('path', "Show only the download path."),
('filename', "Show only download filename."),
('both', "Show download path and filename."))),
'path'),
'path'),
"What to display in the download filename input."),
('timestamp-format',
@ -547,14 +550,14 @@ def data(readonly=False):
"Behavior when the last tab is closed."),
('show',
SettingValue(typ.String(
valid_values=typ.ValidValues(
('always', "Always show the tab bar."),
('never', "Always hide the tab bar."),
('multiple', "Hide the tab bar if only one tab "
"is open."),
('switching', "Show the tab bar when switching "
"tabs.")
SettingValue(
typ.String(valid_values=typ.ValidValues(
('always', "Always show the tab bar."),
('never', "Always hide the tab bar."),
('multiple', "Hide the tab bar if only one tab "
"is open."),
('switching', "Show the tab bar when switching "
"tabs.")
)), 'always'),
"When to show the tab bar"),

View File

@ -219,7 +219,7 @@ class MappingType(BaseType):
def __init__(self, none_ok=False,
valid_values=None):
super().__init__(none_ok)
self.valid_values = valid_values;
self.valid_values = valid_values
if list(sorted(self.MAPPING)) != list(sorted(self.valid_values)):
raise ValueError("Mapping {!r} doesn't match valid values "
"{!r}".format(self.MAPPING, self.valid_values))
@ -284,6 +284,10 @@ class List(BaseType):
"""Base class for a (string-)list setting."""
def __init__(self, none_ok=False, valid_values=None):
super().__init__(none_ok)
self.valid_values = valid_values
def transform(self, value):
if not value:
return None
@ -309,6 +313,9 @@ class FlagList(List):
combinable_values = None
def __init__(self, none_ok=False, valid_values=None):
super().__init__(none_ok, valid_values)
def validate(self, value):
self._basic_validation(value)
if not value:
@ -662,12 +669,12 @@ class ColorSystem(MappingType):
def __init__(self, none_ok=False):
super().__init__(
none_ok,
valid_values = ValidValues(
valid_values=ValidValues(
('rgb', "Interpolate in the RGB color system."),
('hsv', "Interpolate in the HSV color system."),
('hsl', "Interpolate in the HSL color system."),
('none', "Don't show a gradient.")))
MAPPING = {
'rgb': QColor.Rgb,
'hsv': QColor.Hsv,
@ -1220,10 +1227,12 @@ class FuzzyUrl(BaseType):
PaddingValues = collections.namedtuple('PaddingValues', ['top', 'bottom',
'left', 'right'])
class Padding(IntList):
"""Setting for paddings around elements."""
def validate(self, value):
self._basic_validation(value)
if not value:
@ -1346,7 +1355,7 @@ class Position(MappingType):
def __init__(self, none_ok=False):
super().__init__(
none_ok,
valid_values = ValidValues('top', 'bottom', 'left', 'right'))
valid_values=ValidValues('top', 'bottom', 'left', 'right'))
class VerticalPosition(BaseType):
@ -1410,7 +1419,7 @@ class SelectOnRemove(MappingType):
def __init__(self, none_ok=False):
super().__init__(
none_ok,
valid_values = ValidValues(
valid_values=ValidValues(
('left', "Select the tab on the left."),
('right', "Select the tab on the right."),
('previous', "Select the previously selected tab.")))
@ -1434,7 +1443,7 @@ class ConfirmQuit(FlagList):
('downloads', "Show a confirmation if "
"downloads are running"),
('never', "Never show a confirmation."))
def validate(self, value):
super().validate(value)
if not value: