1def _IsColor(color): 2 """Try to determine if color is a hex color string. 3 Labels that look like hex colors will match too, unfortunately.""" 4 if not isinstance(color, basestring): 5 return False 6 color = color.strip('#') 7 if len(color) != 3 and len(color) != 6: 8 return False 9 hex_letters = '0123456789abcdefABCDEF' 10 for letter in color: 11 if letter not in hex_letters: 12 return False 13 return True 14