Commits

Maciej Fijalkowski  committed dde7241

fix for weird classes (pdb is intentiional)

  • Participants
  • Parent commits 0af34b2

Comments (0)

Files changed (3)

File _jitviewer/parser.py

 import re
+import cgi
 from pypy.tool.jitlogparser import parser
 
 class Html(str):
 
 
 def cssclass(cls, s, **kwds):
+    cls = re.sub("[^\w]", "_", cls)
     attrs = ['%s="%s"' % (name, value) for name, value in kwds.iteritems()]
-    return '<span class="%s" %s>%s</span>' % (cls, ' '.join(attrs), s)
+    return '<span class="%s" %s>%s</span>' % (cls, ' '.join(attrs),
+                                              cgi.escape(s))
 
 
 def _new_binop(name):
-    import cgi
     name = cgi.escape(name)
     def f(self):
         return '%s = %s %s %s' % (self.getres(), self.getarg(0), name, self.getarg(1))
 class TraceForOpcodeHtml(parser.TraceForOpcode):
 
     def html_repr(self):
+        #import pdb
+        #pdb.set_trace()
         if self.filename is not None:
             code = self.getcode()
             if code is None:

File _jitviewer/test/test_parser.py

     html = op.html_repr()
     p0 = cssclass('p0', 'p0', onmouseover="highlight_var(this)", onmouseout="disable_var(this)")
     assert p0 in html
+
+def test_cssclass():
+    s = cssclass('asd$%', 'v')
+    print s.__class__, s
+    assert '$' not in s

File bin/jitviewer.py

             orig___init__(self2, *args, **kwds)
         BaseServer.__init__ = __init__
 
-
-class CheckingLoopStorage(LoopStorage):
-    def disassemble_code(self, fname, startlineno, name):
-        result = super(CheckingLoopStorage, self).disassemble_code(fname, startlineno, name)
-        #if result is None and fname is not None:
-        #    raise CannotFindFile(fname)
-        return result
-
-
 def main():
     PATH = os.path.join(os.path.dirname((_jitviewer.__file__)))
     print PATH
         port = 5000
     else:
         port = int(sys.argv[2])
-    storage = CheckingLoopStorage(extra_path)
+    storage = LoopStorage(extra_path)
     log, loops = import_log(filename, ParserWithHtmlRepr)
     parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
     storage.reconnect_loops(loops)