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."), "last loaded session."),
('url-incdec-segments', ('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 " "The URL segments where `:navigate increment/decrement` will "
"search for a number."), "search for a number."),
@ -402,8 +405,8 @@ def data(readonly=False):
"Automatically open completion when typing."), "Automatically open completion when typing."),
('download-path-suggestion', ('download-path-suggestion',
SettingValue(typ.String( SettingValue(
valid_values=typ.ValidValues( typ.String(valid_values=typ.ValidValues(
('path', "Show only the download path."), ('path', "Show only the download path."),
('filename', "Show only download filename."), ('filename', "Show only download filename."),
('both', "Show download path and filename."))), ('both', "Show download path and filename."))),
@ -547,8 +550,8 @@ def data(readonly=False):
"Behavior when the last tab is closed."), "Behavior when the last tab is closed."),
('show', ('show',
SettingValue(typ.String( SettingValue(
valid_values=typ.ValidValues( typ.String(valid_values=typ.ValidValues(
('always', "Always show the tab bar."), ('always', "Always show the tab bar."),
('never', "Always hide the tab bar."), ('never', "Always hide the tab bar."),
('multiple', "Hide the tab bar if only one tab " ('multiple', "Hide the tab bar if only one tab "

View File

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