changeset 76:03e044b5bcc2 draft py2.6

fix escaping of javascript literals
author Jan Kanis <jan.code@jankanis.nl>
date Wed, 18 Jun 2014 16:58:25 +0200
parents 67b1a319c6dc
children 4d2c25baf5a3
files blast2html.py
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/blast2html.py	Wed Jun 18 16:21:45 2014 +0200
+++ b/blast2html.py	Wed Jun 18 16:58:25 2014 +0200
@@ -173,18 +173,19 @@
 # javascript escape filter based on Django's, from https://github.com/dsissitka/khan-website/blob/master/templatefilters.py#L112-139
 # I've removed the html escapes, since html escaping is already being performed by the template engine.
 
+# The r'\u0027' syntax doesn't work the way we need to in python 2.6 with unicode_literals
 _base_js_escapes = (
-    ('\\', r'\u005C'),
-    ('\'', r'\u0027'),
-    ('"', r'\u0022'),
-    # ('>', r'\u003E'),
-    # ('<', r'\u003C'),
-    # ('&', r'\u0026'),
-    # ('=', r'\u003D'),
-    # ('-', r'\u002D'),
-    # (';', r'\u003B'),
-    # (u'\u2028', r'\u2028'),
-    # (u'\u2029', r'\u2029')
+    ('\\', '\\u005C'),
+    ('\'', '\\u0027'),
+    ('"', '\\u0022'),
+    # ('>', '\\u003E'),
+    # ('<', '\\u003C'),
+    # ('&', '\\u0026'),
+    # ('=', '\\u003D'),
+    # ('-', '\\u002D'),
+    # (';', '\\u003B'),
+    (u'\u2028', '\\u2028'),
+    (u'\u2029', '\\u2029')
 )
 
 # Escape every ASCII character with a value less than 32. This is
@@ -337,7 +338,6 @@
 
 
 def main():
-    #import pdb; pdb.set_trace()
     default_template = path.join(path.dirname(__file__), 'blast2html.html.jinja')
 
     parser = argparse.ArgumentParser(description="Convert a BLAST XML result into a nicely readable html page",