File: debian_paths

package info (click to toggle)
python-mne 0.8.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 87,892 kB
  • ctags: 6,639
  • sloc: python: 54,697; makefile: 165; sh: 15
file content (56 lines) | stat: -rw-r--r-- 2,230 bytes parent folder | download
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
51
52
53
54
55
56
From: Michael Hanke <michael.hanke@gmail.com>
Subject: Debian path config for ext. depdendencies

This should deal with the issue of minified javascript libs, by using system
libs. This does not deal with the missing bootstrap v3 library (the Debian
package seems stuck on v2).

The idea is to patch upstream to use system libs, whenever they are giving by
their absolute path.

Additional overhead comes from UTF-8 encoding handling that differs between
Python 2x and 3x.
--- a/mne/report.py
+++ b/mne/report.py
@@ -29,7 +29,7 @@
 from .externals.decorator import decorator
 from .externals.tempita import HTMLTemplate, Template
 from .externals.six import BytesIO
-from .externals.six import moves
+from .externals.six import moves, PY3
 
 tempdir = _TempDir()
 temp_fname = op.join(tempdir, 'test')
@@ -712,21 +712,27 @@
         """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)