From 68135d0fa61b53bb29f9ce1425a98f340a5a7833 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Sat, 9 Sep 2017 12:50:35 +0200 Subject: [PATCH] Remove more unused utils code --- mygpo/publisher/utils.py | 38 -------------------------------------- mygpo/web/templatetags/charts.py | 28 ---------------------------- 2 files changed, 66 deletions(-) diff --git a/mygpo/publisher/utils.py b/mygpo/publisher/utils.py index 38136865..044aca11 100644 --- a/mygpo/publisher/utils.py +++ b/mygpo/publisher/utils.py @@ -103,41 +103,3 @@ def check_publisher_permission(user, podcast): return True return PublishedPodcast.objects.filter(publisher=user, podcast=podcast).exists() - - -def colour_repr(val, max_val, colours): - """ - returns a color representing the given value within a color gradient. - - The color gradient is given by a list of (r, g, b) tupels. The value - is first located within two colors (of the list) and then approximated - between these two colors, based on its position within this segment. - """ - if len(colours) == 1: - return colours[0] - - if max_val == 0: - return colours[0] - - # calculate position in the gradient; defines the segment - pos = float(val) / max_val - colour_nr1 = min(len(colours)-1, int(pos * (len(colours)-1))) - colour_nr2 = min(len(colours)-1, colour_nr1+1) - colour1 = colours[ colour_nr1 ] - colour2 = colours[ colour_nr2 ] - - r1, g1, b1 = colour1 - r2, g2, b2 = colour2 - - # determine bounds of segment - lower_bound = float(max_val) / (len(colours)-1) * colour_nr1 - upper_bound = min(max_val, lower_bound + float(max_val) / (len(colours)-1)) - - # position within the segment - percent = (val - lower_bound) / upper_bound - - r_step = r2 - r1 - g_step = g2 - g1 - b_step = b2 - b1 - - return (r1 + r_step * percent, g1 + g_step * percent, b1 + b_step * percent) diff --git a/mygpo/web/templatetags/charts.py b/mygpo/web/templatetags/charts.py index 9e97b1d0..b4b69382 100644 --- a/mygpo/web/templatetags/charts.py +++ b/mygpo/web/templatetags/charts.py @@ -3,9 +3,6 @@ from django.utils.safestring import mark_safe from django.utils.html import format_html from django.contrib.staticfiles.storage import staticfiles_storage -from mygpo.utils import format_time -from mygpo.publisher.utils import colour_repr - register = template.Library() @@ -71,28 +68,3 @@ def timeline(data): s += '\n' return s - - -@register.filter -def pie_chart(parts): - parts = [ - 'cht=p', - 'chs=250x100', - 'chl=%s' % '|'.join(parts.keys()), - 'chd=t:%s' % ','.join([ repr(x) for x in parts.values() ]) - ] - - s = ' 1: - change -= 1 - return '+{0:.1%}'.format(change) - - # we don't care about negative changes - return '' -- 2.11.4.GIT