Lights now support profiles

This commit is contained in:
Paulus Schoutsen 2014-03-26 00:08:50 -07:00
parent 2890f2d6cc
commit 90769fc0eb
6 changed files with 132 additions and 34 deletions

View file

@ -105,15 +105,10 @@ def color_RGB_to_xy(R, G, B):
return X / (X + Y + Z), Y / (X + Y + Z)
def dict_get_convert(dic, key, value_type, default=None):
""" Get a value from a dic and ensure it is value_type. """
return convert(dic[key], value_type, default) if key in dic else default
def convert(value, to_type, default=None):
""" Converts value to to_type, returns default if fails. """
try:
return to_type(value)
return default if value is None else to_type(value)
except ValueError:
# If value could not be converted
return default