Skip to content

Commit

Permalink
Merge pull request #2254 from JelleZijlstra/patch-2
Browse files Browse the repository at this point in the history
fix usage of "unicode" in glyph.py for Python 3
  • Loading branch information
DanCech committed Mar 6, 2018
2 parents 1de9f70 + 63594f9 commit 42226ae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions webapp/graphite/render/glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from six.moves.configparser import SafeConfigParser
from django.conf import settings
import pytz
import six

from graphite.render.datalib import TimeSeries
from graphite.util import json, BytesIO
Expand Down Expand Up @@ -594,7 +595,7 @@ def setColor(self, value, alpha=1.0, forceAlpha=False):
r,g,b = value
elif value in colorAliases:
r,g,b = colorAliases[value]
elif type(value) in (str,unicode) and len(value) >= 6:
elif isinstance(value, six.string_types) and len(value) >= 6:
s = value
if s[0] == '#': s = s[1:]
if s[0:3] == '%23': s = s[3:]
Expand Down Expand Up @@ -985,7 +986,7 @@ def drawGraph(self,**params):
if 'yUnitSystem' not in params:
params['yUnitSystem'] = 'si'
else:
params['yUnitSystem'] = unicode(params['yUnitSystem']).lower()
params['yUnitSystem'] = six.text_type(params['yUnitSystem']).lower()
if params['yUnitSystem'] not in UnitSystems:
params['yUnitSystem'] = 'si'

Expand Down Expand Up @@ -1044,11 +1045,11 @@ def drawGraph(self,**params):
self.setColor( self.foregroundColor )

if params.get('title'):
self.drawTitle( unicode( unquote_plus(params['title']) ) )
self.drawTitle( six.text_type( unquote_plus(params['title']) ) )
if params.get('vtitle'):
self.drawVTitle( unicode( unquote_plus(params['vtitle']) ) )
self.drawVTitle( six.text_type( unquote_plus(params['vtitle']) ) )
if self.secondYAxis and params.get('vtitleRight'):
self.drawVTitle( unicode( unquote_plus(params['vtitleRight']) ), rightAlign=True )
self.drawVTitle( six.text_type( unquote_plus(params['vtitleRight']) ), rightAlign=True )
self.setFont()

if not params.get('hideLegend', len(self.data) > settings.LEGEND_MAX_ITEMS):
Expand Down Expand Up @@ -1850,7 +1851,7 @@ def drawLabels(self):
if slice['value'] < 10 and slice['value'] != int(slice['value']):
label = "%.2f" % slice['value']
else:
label = unicode(int(slice['value']))
label = six.text_type(int(slice['value']))
theta = slice['midAngle']
x = self.x0 + (self.radius / 2.0 * math.cos(theta))
y = self.y0 + (self.radius / 2.0 * math.sin(theta))
Expand Down

0 comments on commit 42226ae

Please sign in to comment.