Fix minor issue in _ColorHandler
This commit is contained in:
@@ -54,10 +54,10 @@ class _ColorsHandler:
|
|||||||
All relevant features are defined:
|
All relevant features are defined:
|
||||||
- if the format is valid;
|
- if the format is valid;
|
||||||
- if 'line' represent a single color or a list of colors.
|
- if 'line' represent a single color or a list of colors.
|
||||||
- the quality of the color."""
|
- the 'quality' of the color."""
|
||||||
quality, color_str = line.split(ThemeConstants.COLOR_SEPARATOR)
|
quality, color_str = line.split(ThemeConstants.COLOR_SEPARATOR)
|
||||||
color_str = color_str.rstrip()
|
color_str = color_str.strip()
|
||||||
self.quality = quality.lower()
|
self.quality = quality.lower().strip()
|
||||||
self.color_str = ''
|
self.color_str = ''
|
||||||
self.color_list = []
|
self.color_list = []
|
||||||
if ',' in color_str:
|
if ',' in color_str:
|
||||||
@@ -71,9 +71,9 @@ class _ColorsHandler:
|
|||||||
def __color_is_valid(self):
|
def __color_is_valid(self):
|
||||||
"""Return if the color (or the list of colors) has a valid html format."""
|
"""Return if the color (or the list of colors) has a valid html format."""
|
||||||
pattern = "#([a-zA-Z0-9]){6}"
|
pattern = "#([a-zA-Z0-9]){6}"
|
||||||
match_ok = lambda col: bool(re.match(pattern, col))
|
match_ok = lambda col: bool(re.match(pattern, col)) and len(col) == 7
|
||||||
if not self.is_simple_string:
|
if not self.is_simple_string:
|
||||||
if self.elements == self.MAX_COLORS:
|
if len(self.color_list) <= self.MAX_COLORS:
|
||||||
return all(match_ok(c) for c in self.color_list)
|
return all(match_ok(c) for c in self.color_list)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@@ -101,7 +101,7 @@ class _ColorsHandler:
|
|||||||
simple_color_list.append(color)
|
simple_color_list.append(color)
|
||||||
else:
|
else:
|
||||||
double_color_list.append(color)
|
double_color_list.append(color)
|
||||||
if simple_color_list and double_color_list:
|
if simple_color_list or double_color_list:
|
||||||
return cls(simple_color_list, double_color_list)
|
return cls(simple_color_list, double_color_list)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user