Commits

Olemis Lang committed 209b4c8

GViz QL : str values instead of unicode for formatted values

  • Participants
  • Parent commits ab44924
  • Branches gviz_ql

Comments (0)

Files changed (2)

File trac-dev/gviz/tracgviz/gvizql.py

       return formatter[idx]
     elif coltype in cls.DATETIME_CONVERTER:
       # Formatter is an instance of PyICU.SimpleDateFormat
-      return formatter.format(cls.DATETIME_CONVERTER[coltype](value))
+      return formatter.format(cls.DATETIME_CONVERTER[coltype](value)) \
+          .encode('utf8')
     elif coltype == 'number':
       # Formatter is an instance of PyICU.DecimalFormat
-      return formatter.format(value)
+      return formatter.format(value).encode('utf8')
     else:
       raise GVizRuntimeError("Format not supported for %s type" % (coltype,))
 
       raise LookupError("Unknown column '%s'" % (colnm,))
     coltype = col[1]
     if coltype == 'boolean':
-      pattern = pattern.rsplit(':', 1)
+      pattern = pattern.encode('utf-8').rsplit(':', 1)
       if len(pattern) != 2:
         raise GVizRuntimeError("Invalid formatting pattern '%s'" % (pattern,))
       else:

File trac-dev/gviz/tracgviz/testing/test_gvizql.py

          name = John
          dept = Eng
          lunchTime = 12:00:00
-         salary = (1000, u'1,000.00')
+         salary = (1000, '1,000.00')
          hireDate = 2005-03-19
          age = 35
          isSenior = True
          name = Dave
          dept = Eng
          lunchTime = 12:00:00
-         salary = (500, u'500.00')
+         salary = (500, '500.00')
          hireDate = 2006-04-19
          age = 27
          isSenior = False
          name = Sally
          dept = Eng
          lunchTime = 13:00:00
-         salary = (600, u'600.00')
+         salary = (600, '600.00')
          hireDate = 2005-10-10
          age = 30
          isSenior = False
          name = Ben
          dept = Sales
          lunchTime = 12:00:00
-         salary = (400, u'400.00')
+         salary = (400, '400.00')
          hireDate = 2002-10-10
          age = 32
          isSenior = True
          name = Dana
          dept = Sales
          lunchTime = 12:00:00
-         salary = (350, u'350.00')
+         salary = (350, '350.00')
          hireDate = 2004-09-08
          age = 25
          isSenior = False
          name = Mike
          dept = Marketing
          lunchTime = 13:00:00
-         salary = (800, u'800.00')
+         salary = (800, '800.00')
          hireDate = 2005-01-10
          age = 24
          isSenior = True
          name = John
          dept = Eng
          lunchTime = 12:00:00
-         salary = (1000, u'1,000.00')
-         hireDate = (datetime.date(2005, 3, 19), u'19-Mar-2005')
+         salary = (1000, '1,000.00')
+         hireDate = (datetime.date(2005, 3, 19), '19-Mar-2005')
          age = 35
          isSenior = (True, 'not yet')
          seniorityStartTime = 2007-12-02 15:56:00
          name = Dave
          dept = Eng
          lunchTime = 12:00:00
-         salary = (500, u'500.00')
-         hireDate = (datetime.date(2006, 4, 19), u'19-Apr-2006')
+         salary = (500, '500.00')
+         hireDate = (datetime.date(2006, 4, 19), '19-Apr-2006')
          age = 27
          isSenior = (False, 'of course!')
          seniorityStartTime = None
          name = Sally
          dept = Eng
          lunchTime = 13:00:00
-         salary = (600, u'600.00')
-         hireDate = (datetime.date(2005, 10, 10), u'10-Oct-2005')
+         salary = (600, '600.00')
+         hireDate = (datetime.date(2005, 10, 10), '10-Oct-2005')
          age = 30
          isSenior = (False, 'of course!')
          seniorityStartTime = None
          name = Ben
          dept = Sales
          lunchTime = 12:00:00
-         salary = (400, u'400.00')
-         hireDate = (datetime.date(2002, 10, 10), u'10-Oct-2002')
+         salary = (400, '400.00')
+         hireDate = (datetime.date(2002, 10, 10), '10-Oct-2002')
          age = 32
          isSenior = (True, 'not yet')
          seniorityStartTime = 2005-03-09 12:30:00
          name = Dana
          dept = Sales
          lunchTime = 12:00:00
-         salary = (350, u'350.00')
-         hireDate = (datetime.date(2004, 9, 8), u'08-Sep-2004')
+         salary = (350, '350.00')
+         hireDate = (datetime.date(2004, 9, 8), '08-Sep-2004')
          age = 25
          isSenior = (False, 'of course!')
          seniorityStartTime = None
          name = Mike
          dept = Marketing
          lunchTime = 13:00:00
-         salary = (800, u'800.00')
-         hireDate = (datetime.date(2005, 1, 10), u'10-Jan-2005')
+         salary = (800, '800.00')
+         hireDate = (datetime.date(2005, 1, 10), '10-Jan-2005')
          age = 24
          isSenior = (True, 'not yet')
          seniorityStartTime = 2007-12-30 14:40:00
          name = John
          dept = Eng
          lunchTime = 12:00:00
-         salary = (1000, u'1,000.00')
-         hireDate = (datetime.date(2005, 3, 19), u'19-Mar-2005')
+         salary = (1000, '1,000.00')
+         hireDate = (datetime.date(2005, 3, 19), '19-Mar-2005')
          age = 35
          isSenior = (True, 'Yes!')
          seniorityStartTime = 2007-12-02 15:56:00
          name = Dave
          dept = Eng
          lunchTime = 12:00:00
-         salary = (500, u'500.00')
-         hireDate = (datetime.date(2006, 4, 19), u'19-Apr-2006')
+         salary = (500, '500.00')
+         hireDate = (datetime.date(2006, 4, 19), '19-Apr-2006')
          age = 27
          isSenior = (False, 'Not yet')
          seniorityStartTime = None
          name = Sally
          dept = Eng
          lunchTime = 13:00:00
-         salary = (600, u'600.00')
-         hireDate = (datetime.date(2005, 10, 10), u'10-Oct-2005')
+         salary = (600, '600.00')
+         hireDate = (datetime.date(2005, 10, 10), '10-Oct-2005')
          age = 30
          isSenior = (False, 'Not yet')
          seniorityStartTime = None
          name = Ben
          dept = Sales
          lunchTime = 12:00:00
-         salary = (400, u'400.00')
-         hireDate = (datetime.date(2002, 10, 10), u'10-Oct-2002')
+         salary = (400, '400.00')
+         hireDate = (datetime.date(2002, 10, 10), '10-Oct-2002')
          age = 32
          isSenior = (True, 'Yes!')
          seniorityStartTime = 2005-03-09 12:30:00
          name = Dana
          dept = Sales
          lunchTime = 12:00:00
-         salary = (350, u'350.00')
-         hireDate = (datetime.date(2004, 9, 8), u'08-Sep-2004')
+         salary = (350, '350.00')
+         hireDate = (datetime.date(2004, 9, 8), '08-Sep-2004')
          age = 25
          isSenior = (False, 'Not yet')
          seniorityStartTime = None
          name = Mike
          dept = Marketing
          lunchTime = 13:00:00
-         salary = (800, u'800.00')
-         hireDate = (datetime.date(2005, 1, 10), u'10-Jan-2005')
+         salary = (800, '800.00')
+         hireDate = (datetime.date(2005, 1, 10), '10-Jan-2005')
          age = 24
          isSenior = (True, 'Yes!')
          seniorityStartTime = 2007-12-30 14:40:00
       isSenior boolean
       lunchTime timeofday
       = Row =
-         salary = (1000, u'1,000.00')
-         hireDate = (datetime.date(2005, 3, 19), u'19-Mar-2005')
+         salary = (1000, '1,000.00')
+         hireDate = (datetime.date(2005, 3, 19), '19-Mar-2005')
          isSenior = (True, 'Yes!')
          lunchTime = 12:00:00
       = Row =
-         salary = (500, u'500.00')
-         hireDate = (datetime.date(2006, 4, 19), u'19-Apr-2006')
+         salary = (500, '500.00')
+         hireDate = (datetime.date(2006, 4, 19), '19-Apr-2006')
          isSenior = (False, 'Not yet')
          lunchTime = 12:00:00
       = Row =
-         salary = (600, u'600.00')
-         hireDate = (datetime.date(2005, 10, 10), u'10-Oct-2005')
+         salary = (600, '600.00')
+         hireDate = (datetime.date(2005, 10, 10), '10-Oct-2005')
          isSenior = (False, 'Not yet')
          lunchTime = 13:00:00
       = Row =
-         salary = (400, u'400.00')
-         hireDate = (datetime.date(2002, 10, 10), u'10-Oct-2002')
+         salary = (400, '400.00')
+         hireDate = (datetime.date(2002, 10, 10), '10-Oct-2002')
          isSenior = (True, 'Yes!')
          lunchTime = 12:00:00
       = Row =
-         salary = (350, u'350.00')
-         hireDate = (datetime.date(2004, 9, 8), u'08-Sep-2004')
+         salary = (350, '350.00')
+         hireDate = (datetime.date(2004, 9, 8), '08-Sep-2004')
          isSenior = (False, 'Not yet')
          lunchTime = 12:00:00
       = Row =
-         salary = (800, u'800.00')
-         hireDate = (datetime.date(2005, 1, 10), u'10-Jan-2005')
+         salary = (800, '800.00')
+         hireDate = (datetime.date(2005, 1, 10), '10-Jan-2005')
          isSenior = (True, 'Yes!')
          lunchTime = 13:00:00
 
          lower(name) + '@example.com' = john@example.com
          upper(dept) = ENG
          isSenior = (True, 'SKILLED')
-         seniorityStartTime = (datetime.datetime(2007, 12, 2, 15, 56), u"Sun, Dec 2, '07")
-         salary * 0.05 = (50.0, u'50.00')
+         seniorityStartTime = (datetime.datetime(2007, 12, 2, 15, 56), "Sun, Dec 2, '07")
+         salary * 0.05 = (50.0, '50.00')
       = Row =
          lower(name) + '@example.com' = dave@example.com
          upper(dept) = ENG
          isSenior = (False, 'beginner')
          seniorityStartTime = None
-         salary * 0.05 = (25.0, u'25.00')
+         salary * 0.05 = (25.0, '25.00')
       = Row =
          lower(name) + '@example.com' = sally@example.com
          upper(dept) = ENG
          isSenior = (False, 'beginner')
          seniorityStartTime = None
-         salary * 0.05 = (30.0, u'30.00')
+         salary * 0.05 = (30.0, '30.00')
       = Row =
          lower(name) + '@example.com' = ben@example.com
          upper(dept) = SALES
          isSenior = (True, 'SKILLED')
-         seniorityStartTime = (datetime.datetime(2005, 3, 9, 12, 30), u"Wed, Mar 9, '05")
-         salary * 0.05 = (20.0, u'20.00')
+         seniorityStartTime = (datetime.datetime(2005, 3, 9, 12, 30), "Wed, Mar 9, '05")
+         salary * 0.05 = (20.0, '20.00')
       = Row =
          lower(name) + '@example.com' = dana@example.com
          upper(dept) = SALES
          isSenior = (False, 'beginner')
          seniorityStartTime = None
-         salary * 0.05 = (17.5, u'17.50')
+         salary * 0.05 = (17.5, '17.50')
       = Row =
          lower(name) + '@example.com' = mike@example.com
          upper(dept) = MARKETING
          isSenior = (True, 'SKILLED')
-         seniorityStartTime = (datetime.datetime(2007, 12, 30, 14, 40), u"Sun, Dec 30, '07")
-         salary * 0.05 = (40.0, u'40.00')
-
+         seniorityStartTime = (datetime.datetime(2007, 12, 30, 14, 40), "Sun, Dec 30, '07")
+         salary * 0.05 = (40.0, '40.00')
 
       """,
   'Parsing OPTIONS' : r"""