Skip to content

Commit

Permalink
Removing unused ColorFactory (in js now)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 7, 2016
1 parent 46690d3 commit 7525ab7
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions caravel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import unicode_literals

from datetime import datetime
import hashlib
import functools
import json
import logging
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7525ab7

Please sign in to comment.