diff --git a/caravel/utils.py b/caravel/utils.py index 4e3579f5fe12..05fb32528746 100644 --- a/caravel/utils.py +++ b/caravel/utils.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals from datetime import datetime -import hashlib import functools import json import logging @@ -137,43 +136,6 @@ def process_result_value(self, value, dialect): return value -class ColorFactory(object): - - """Used to generated arrays of colors server side""" - - BNB_COLORS = [ - # rausch hackb kazan babu lima beach barol - '#ff5a5f', '#7b0051', '#007A87', '#00d1c1', '#8ce071', '#ffb400', '#b4a76c', - '#ff8083', '#cc0086', '#00a1b3', '#00ffeb', '#bbedab', '#ffd266', '#cbc29a', - '#ff3339', '#ff1ab1', '#005c66', '#00b3a5', '#55d12e', '#b37e00', '#988b4e', - ] - - def __init__(self, hash_based=False): - self.d = {} - self.hash_based = hash_based - - def get(self, s): - """Gets a color from a string and memoize the association - - >>> cf = ColorFactory() - >>> cf.get('item_1') - u'#ff5a5f' - >>> cf.get('item_2') - u'#7b0051' - >>> cf.get('item_1') - u'#ff5a5f' - """ - if self.hash_based: - s = s.encode('utf-8') - h = hashlib.md5(s) - i = int(h.hexdigest(), 16) - else: - if s not in self.d: - self.d[s] = len(self.d) - i = self.d[s] - return self.BNB_COLORS[i % len(self.BNB_COLORS)] - - def init(caravel): """Inits the Caravel application with security roles and such""" db = caravel.db