Skip to content
Snippets Groups Projects
Commit 6a99c94b authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Python 3: remove use of unicode()

parent 5236e2f5
No related branches found
No related tags found
No related merge requests found
......@@ -1281,7 +1281,7 @@ class EventLogTagDetail(InheritPermissionsAPIView):
# client that the creation was sucessful when, in fact, the database
# was unchanged.
tag = eventlog.tags.filter(name=tagname)[0]
msg = "Log already has tag %s" % unicode(tag)
msg = "Log already has tag {0}".format(tag.name)
return Response(msg,status=status.HTTP_409_CONFLICT)
except:
# Check authorization
......
......@@ -19,9 +19,6 @@ def getLogsForTag(event,name=None):
# In either case, we want the template to just ignore it.
return None
@register.filter("tagUnicode")
def tagUnicode(tag):
return unicode(tag);
@register.filter("logsForTagHaveImage")
def logsForTagAllHaveImages(event,name=None):
......
from builtins import str
from decimal import Decimal, InvalidOperation, ROUND_HALF_UP
from django import template
from django.utils.encoding import force_text
......@@ -61,7 +62,7 @@ def scientificformat(text):
elif ( (d > Decimal('-100') and d < Decimal('-0.1')) or ( d > Decimal('0.1') and d < Decimal('100')) ) :
# this is what the original floatformat() function does
sign, digits, exponent = d.quantize(Decimal('.01'), ROUND_HALF_UP).as_tuple()
digits = [unicode(digit) for digit in reversed(digits)]
digits = [str(digit) for digit in reversed(digits)]
while len(digits) <= abs(exponent):
digits.append(u'0')
digits.insert(-exponent, u'.')
......@@ -72,7 +73,7 @@ def scientificformat(text):
# for very small and very large numbers
sign, digits, exponent = d.as_tuple()
exponent = d.adjusted()
digits = [unicode(digit) for digit in digits][:3] # limit to 2 decimal places
digits = [str(digit) for digit in digits][:3] # limit to 2 decimal places
while len(digits) < 3:
digits.append(u'0')
digits.insert(1, u'.')
......
from builtins import str
import datetime
import ldap
......@@ -33,8 +34,8 @@ class LdapPersonResultProcessor(object):
if self.ldap_connection is None:
raise RuntimeError('LDAP connection not configured')
self.user_data = {
'first_name': unicode(self.ldap_result['givenName'][0], 'utf-8'),
'last_name': unicode(self.ldap_result['sn'][0], 'utf-8'),
'first_name': str(self.ldap_result['givenName'][0], 'utf-8'),
'last_name': str(self.ldap_result['sn'][0], 'utf-8'),
'email': self.ldap_result['mail'][0],
'is_active': self.ldap_connection.lvc_group.ldap_name in
self.ldap_result.get('isMemberOf', []),
......@@ -239,7 +240,7 @@ class LdapRobotResultProcessor(LdapPersonResultProcessor):
if self.ldap_connection is None:
raise RuntimeError('LDAP connection not configured')
self.user_data = {
'last_name': unicode(self.ldap_result['x-LIGO-TWikiName'][0],
'last_name': str(self.ldap_result['x-LIGO-TWikiName'][0],
'utf-8'),
'email': self.ldap_result['mail'][0],
'is_active': self.ldap_connection.groups.get(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment