File: 00-unminified-js-path.patch

package info (click to toggle)
plotly 3.6.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 68,392 kB
  • sloc: python: 259,604; sh: 58; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 1,103 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
Description: Changes path to use plotly offline javascript file.
Author: Josue Ortega <josue@debian.org>
Last-Update: 2018-11-25

--- a/plotly/offline/offline.py
+++ b/plotly/offline/offline.py
@@ -6,6 +6,7 @@
 from __future__ import absolute_import
 
 import os
+import sys
 import uuid
 import warnings
 import pkgutil
@@ -93,8 +94,19 @@
     >>> with open('multi_plot.html', 'w') as f:
     ...      f.write(html)
     """
-    path = os.path.join('package_data', 'plotly.min.js')
-    plotlyjs = pkgutil.get_data('plotly', path).decode('utf-8')
+    def get_debian_file():
+        py_version = sys.version_info[0]
+        debian_path = '/usr/share/python-plotly/plotly.js'
+        if py_version == 3:
+            debian_path = '/usr/share/python3-plotly/plotly.js'
+        plotly_js_data = None
+        with open(debian_path, 'r') as file_:
+            plotly_js_data = file_.read()
+        if py_version == 3:
+            return plotly_js_data.encode('utf-8').decode('utf-8')
+        else:
+           return str(plotly_js_data)
+    plotlyjs = get_debian_file()
     return plotlyjs