Skip to content

Commit

Permalink
use six.text_type
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCech committed Dec 20, 2017
1 parent cd12cff commit 018356b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
12 changes: 4 additions & 8 deletions webapp/graphite/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from functools import reduce
import pytz
from six import text_type
from six.moves.urllib.parse import unquote_plus

from datetime import datetime
Expand Down Expand Up @@ -335,18 +336,13 @@ def msgpack_nodes(nodes):
nodes_info = []

# make sure everything is unicode in python 2.x and 3.x
try:
unicode = str
except:
pass

for node in nodes:
info = {
unicode('path'): unicode(node.path),
unicode('is_leaf'): node.is_leaf,
text_type('path'): text_type(node.path),
text_type('is_leaf'): node.is_leaf,
}
if node.is_leaf:
info[unicode('intervals')] = [interval.tuple for interval in node.intervals]
info[text_type('intervals')] = [interval.tuple for interval in node.intervals]

nodes_info.append(info)

Expand Down
24 changes: 10 additions & 14 deletions webapp/graphite/render/datalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import collections
import re
import time
from six import text_type

from django.conf import settings

Expand Down Expand Up @@ -121,21 +122,16 @@ def __repr__(self):
def getInfo(self):
"""Pickle-friendly representation of the series"""
# make sure everything is unicode in python 2.x and 3.x
try:
unicode = str
except:
pass

return {
unicode('name') : unicode(self.name),
unicode('start') : self.start,
unicode('end') : self.end,
unicode('step') : self.step,
unicode('values') : list(self),
unicode('pathExpression') : unicode(self.pathExpression),
unicode('valuesPerPoint') : self.valuesPerPoint,
unicode('consolidationFunc'): unicode(self.consolidationFunc),
unicode('xFilesFactor') : self.xFilesFactor,
text_type('name') : text_type(self.name),
text_type('start') : self.start,
text_type('end') : self.end,
text_type('step') : self.step,
text_type('values') : list(self),
text_type('pathExpression') : text_type(self.pathExpression),
text_type('valuesPerPoint') : self.valuesPerPoint,
text_type('consolidationFunc'): text_type(self.consolidationFunc),
text_type('xFilesFactor') : self.xFilesFactor,
}


Expand Down

0 comments on commit 018356b

Please sign in to comment.