1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Description: adjust paths to use system-wide packages resources (.js etc)
Author: Jaakko Leppakangas <jaeilepp@student.jyu.fi>
Origin: upstream
Forwarded: not-needed
Reviewed-By: Yaroslav O. Halchenko <debian@onerussian.com>
--- a/mne/report.py
+++ b/mne/report.py
@@ -31,7 +31,7 @@ from .parallel import parallel_func, che
from .externals.tempita import HTMLTemplate, Template
from .externals.six import BytesIO
-from .externals.six import moves
+from .externals.six import moves, PY3
VALID_EXTENSIONS = ['raw.fif', 'raw.fif.gz', 'sss.fif', 'sss.fif.gz',
'-eve.fif', '-eve.fif.gz', '-cov.fif', '-cov.fif.gz',
@@ -1187,21 +1187,27 @@ class Report(object):
"""Initialize the renderer.
"""
- inc_fnames = ['jquery-1.10.2.min.js', 'jquery-ui.min.js',
+ inc_fnames = ['/usr/share/javascript/jquery/jquery.min.js',
+ '/usr/share/javascript/jquery-ui/jquery-ui.min.js',
'bootstrap.min.js', 'jquery-ui.min.css',
'bootstrap.min.css']
include = list()
for inc_fname in inc_fnames:
logger.info('Embedding : %s' % inc_fname)
- f = open(op.join(op.dirname(__file__), 'html', inc_fname),
- 'r')
+ if not os.path.isabs(inc_fname):
+ inc_fname = op.join(op.dirname(__file__), 'html', inc_fname)
+ f = open(inc_fname, 'r')
+ if PY3:
+ f_contents = f.read()
+ else:
+ f_contents = f.read().decode('UTF-8')
if inc_fname.endswith('.js'):
include.append(u'<script type="text/javascript">' +
- f.read() + u'</script>')
+ f_contents + u'</script>')
elif inc_fname.endswith('.css'):
include.append(u'<style type="text/css">' +
- f.read() + u'</style>')
+ f_contents + u'</style>')
f.close()
self.include = ''.join(include)
|