Some pep8 fixes
This commit is contained in:
@@ -3,14 +3,11 @@ from sqlalchemy import types
|
|||||||
from sqlalchemy_utils import ImproperlyConfigured
|
from sqlalchemy_utils import ImproperlyConfigured
|
||||||
from .scalar_coercible import ScalarCoercible
|
from .scalar_coercible import ScalarCoercible
|
||||||
|
|
||||||
|
colour = None
|
||||||
try:
|
try:
|
||||||
import colour
|
import colour
|
||||||
from colour import Color
|
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
colour = None
|
pass
|
||||||
Color = None
|
|
||||||
|
|
||||||
|
|
||||||
class ColorType(types.TypeDecorator, ScalarCoercible):
|
class ColorType(types.TypeDecorator, ScalarCoercible):
|
||||||
@@ -22,7 +19,7 @@ class ColorType(types.TypeDecorator, ScalarCoercible):
|
|||||||
impl = types.Unicode(20)
|
impl = types.Unicode(20)
|
||||||
|
|
||||||
def __init__(self, max_length=20, *args, **kwargs):
|
def __init__(self, max_length=20, *args, **kwargs):
|
||||||
# Bail if colour is not found.
|
# Fail if colour is not found.
|
||||||
if colour is None:
|
if colour is None:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"'colour' package is required to use 'ColorType'"
|
"'colour' package is required to use 'ColorType'"
|
||||||
@@ -38,10 +35,10 @@ class ColorType(types.TypeDecorator, ScalarCoercible):
|
|||||||
|
|
||||||
def process_result_value(self, value, dialect):
|
def process_result_value(self, value, dialect):
|
||||||
if value:
|
if value:
|
||||||
return Color(value)
|
return colour.Color(value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def _coerce(self, value):
|
def _coerce(self, value):
|
||||||
if value is not None and not isinstance(value, Color):
|
if value is not None and not isinstance(value, colour.Color):
|
||||||
return Color(value)
|
return colour.Color(value)
|
||||||
return value
|
return value
|
||||||
|
Reference in New Issue
Block a user