fixes to config types, remove unneeded derived __init__ and call base __init__

This commit is contained in:
Patric Schmitz 2015-11-25 11:11:30 +01:00
parent 2a705e2eb6
commit 6431542eba

View File

@ -123,9 +123,8 @@ class BaseType:
special = False special = False
def __init__(self, none_ok=False, valid_values=None): def __init__(self, none_ok=False):
self.none_ok = none_ok self.none_ok = none_ok
self.valid_values = valid_values
def _basic_validation(self, value): def _basic_validation(self, value):
"""Do some basic validation for the value (empty, non-printable chars). """Do some basic validation for the value (empty, non-printable chars).
@ -244,7 +243,8 @@ class String(BaseType):
def __init__(self, minlen=None, maxlen=None, forbidden=None, def __init__(self, minlen=None, maxlen=None, forbidden=None,
none_ok=False, completions=None, valid_values=None): none_ok=False, completions=None, valid_values=None):
super().__init__(none_ok, valid_values) super().__init__(none_ok)
self.valid_values = valid_values
if minlen is not None and minlen < 1: if minlen is not None and minlen < 1:
raise ValueError("minlen ({}) needs to be >= 1!".format(minlen)) raise ValueError("minlen ({}) needs to be >= 1!".format(minlen))
elif maxlen is not None and maxlen < 1: elif maxlen is not None and maxlen < 1:
@ -651,8 +651,7 @@ class ColorSystem(MappingType):
special = True special = True
def __init__(self): valid_values = ValidValues(
self.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."),
@ -1095,9 +1094,7 @@ class Proxy(BaseType):
"""A proxy URL or special value.""" """A proxy URL or special value."""
special = True special = True
valid_values = ValidValues(
def __init__(self):
self.valid_values = ValidValues(
('system', "Use the system wide proxy."), ('system', "Use the system wide proxy."),
('none', "Don't use any proxy")) ('none', "Don't use any proxy"))
@ -1209,8 +1206,6 @@ 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."""
@ -1326,8 +1321,7 @@ class Position(MappingType):
"""The position of the tab bar.""" """The position of the tab bar."""
def __init__(self): valid_values = ValidValues('top', 'bottom', 'left', 'right')
self.valid_values = ValidValues('top', 'bottom', 'left', 'right')
MAPPING = { MAPPING = {
'top': QTabWidget.North, 'top': QTabWidget.North,
@ -1341,8 +1335,7 @@ class VerticalPosition(BaseType):
"""The position of the download bar.""" """The position of the download bar."""
def __init__(self): valid_values = ValidValues('top', 'bottom')
self.valid_values = ValidValues('top', 'bottom')
class UrlList(List): class UrlList(List):
@ -1387,8 +1380,8 @@ class SelectOnRemove(MappingType):
"""Which tab to select when the focused tab is removed.""" """Which tab to select when the focused tab is removed."""
special = True special = True
def __init__(self):
self.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."))
@ -1406,8 +1399,7 @@ class ConfirmQuit(FlagList):
special = True special = True
def __init__(self): valid_values = ValidValues(('always', "Always show a confirmation."),
self.valid_values = ValidValues(('always', "Always show a confirmation."),
('multiple-tabs', "Show a confirmation if " ('multiple-tabs', "Show a confirmation if "
"multiple tabs are opened."), "multiple tabs are opened."),
('downloads', "Show a confirmation if " ('downloads', "Show a confirmation if "
@ -1438,8 +1430,7 @@ class NewTabPosition(BaseType):
special = True special = True
def __init__(self): valid_values = ValidValues(
self.valid_values = ValidValues(
('left', "On the left of the current tab."), ('left', "On the left of the current tab."),
('right', "On the right of the current tab."), ('right', "On the right of the current tab."),
('first', "At the left end."), ('first', "At the left end."),
@ -1452,8 +1443,7 @@ class IgnoreCase(Bool):
special = True special = True
def __init__(self): valid_values = ValidValues(
self.valid_values = ValidValues(
('true', "Search case-insensitively"), ('true', "Search case-insensitively"),
('false', "Search case-sensitively"), ('false', "Search case-sensitively"),
('smart', "Search case-sensitively if there " ('smart', "Search case-sensitively if there "
@ -1481,9 +1471,6 @@ class UserAgent(BaseType):
special = True special = True
def __init__(self, none_ok=False):
super().__init__(none_ok)
def validate(self, value): def validate(self, value):
self._basic_validation(value) self._basic_validation(value)