Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bde22fd

Browse filesBrowse files
committed
Switch to new resource-fetching scheme.
1 parent 1825371 commit bde22fd
Copy full SHA for bde22fd

File tree

Expand file treeCollapse file tree

3 files changed

+29
-18
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+29
-18
lines changed

‎plotly/graph_objs/graph_objs_tools.py

Copy file name to clipboardExpand all lines: plotly/graph_objs/graph_objs_tools.py
+23-14Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import textwrap
44
import os
55
import sys
6+
from plotly.resources import (GRAPH_REFERENCE_GRAPH_OBJS_META,
7+
GRAPH_REFERENCE_NAME_TO_KEY,
8+
GRAPH_REFERENCE_KEY_TO_NAME,
9+
GRAPH_REFERENCE_OBJ_MAP, GRAPH_REFERENCE_DIR)
10+
611
if sys.version[:3] == '2.6':
712
try:
813
from ordereddict import OrderedDict
@@ -19,23 +24,27 @@
1924
import json
2025
import six
2126

22-
from pkg_resources import resource_string
23-
2427

25-
# Define graph reference loader
2628
def _load_graph_ref():
27-
graph_reference_dir = 'graph_reference'
28-
json_files = [
29-
'graph_objs_meta.json',
30-
'OBJ_MAP.json',
31-
'NAME_TO_KEY.json',
32-
'KEY_TO_NAME.json'
33-
]
29+
"""
30+
A private method to load the graph reference json files.
31+
32+
:return: (tuple) A tuple of dict objects.
33+
34+
"""
3435
out = []
35-
for json_file in json_files:
36-
relative_path = os.path.join(graph_reference_dir, json_file)
37-
s = resource_string('plotly', relative_path).decode('utf-8')
38-
tmp = json.loads(s, object_pairs_hook=OrderedDict)
36+
37+
# this splits directory path from basenames
38+
filenames = [
39+
os.path.split(GRAPH_REFERENCE_GRAPH_OBJS_META)[-1],
40+
os.path.split(GRAPH_REFERENCE_OBJ_MAP)[-1],
41+
os.path.split(GRAPH_REFERENCE_NAME_TO_KEY)[-1],
42+
os.path.split(GRAPH_REFERENCE_KEY_TO_NAME)[-1]
43+
]
44+
for filename in filenames:
45+
path = os.path.join(sys.prefix, GRAPH_REFERENCE_DIR, filename)
46+
with open(path, 'r') as f:
47+
tmp = json.load(f, object_pairs_hook=OrderedDict)
3948
tmp = utils.decode_unicode(tmp)
4049
out += [tmp]
4150
return tuple(out)

‎plotly/widgets/graph_widget.py

Copy file name to clipboardExpand all lines: plotly/widgets/graph_widget.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import deque
22
import uuid
3+
import os
34
import sys
45

56
# TODO: protected imports?
@@ -10,7 +11,7 @@
1011
import plotly.plotly.plotly as py
1112
from plotly import utils, tools
1213
from plotly.graph_objs import Figure
13-
from pkg_resources import resource_string
14+
from plotly.resources import WIDGETS_DIR, WIDGETS_MAIN_JS
1415

1516
# even though python 2.6 wouldn't be able to run *any* of this...
1617
if sys.version[:3] == '2.6':
@@ -21,8 +22,10 @@
2122
# Load JS widget code
2223
# No officially recommended way to do this in any other way
2324
# http://mail.scipy.org/pipermail/ipython-dev/2014-April/013835.html
24-
js_widget_code = resource_string('plotly',
25-
'widgets/graphWidget.js').decode('utf-8')
25+
js_file_path = os.path.join(sys.prefix, WIDGETS_DIR,
26+
os.path.split(WIDGETS_MAIN_JS)[-1])
27+
with open(js_file_path, 'r') as f:
28+
js_widget_code = f.read().decode('utf-8')
2629

2730
display(Javascript(js_widget_code))
2831

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def readme():
3636
packages=find_packages(),
3737
data_files=[(GRAPH_REFERENCE_DIR, GRAPH_REFERENCE_FILES),
3838
(WIDGETS_DIR, WIDGETS_FILES)],
39-
package_data={'plotly': ['graph_reference/*.json', 'widgets/*.js']},
4039
install_requires=['requests', 'six', 'pytz'],
4140
extras_require={"PY2.6": ['simplejson', 'ordereddict',
4241
'requests[security]']},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.