Skip to content

Commit f5a5d5a

Browse files
committed
Download schema for explicitly defined plotly.js version from the plotly.js github repository.
1 parent 664c88d commit f5a5d5a

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

_plotly_utils/basevalidators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def __init__(self, plotly_name, parent_name, role=None, **_):
161161
plotly_name == 'range' and parent_name == 'layout.xaxis'
162162
role : str
163163
The role string for the property as specified in
164-
default-schema.json
164+
plot-schema.json
165165
"""
166166
self.parent_name = parent_name
167167
self.plotly_name = plotly_name

codegen/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def perform_codegen():
4949

5050
# Load plotly schema
5151
# ------------------
52-
with open('plotly/package_data/default-schema.json', 'r') as f:
52+
with open('plotly/package_data/plot-schema.json', 'r') as f:
5353
plotly_schema = json.load(f)
5454

5555
# Build node lists

codegen/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def write_init_py(pkg_root, path_parts, import_pairs):
141141
'frame.layout': 'plotly.validators.LayoutValidator'
142142
}
143143

144-
# Mapping from property string (as found in default-schema.json) to a custom
144+
# Mapping from property string (as found in plot-schema.json) to a custom
145145
# class name. If not included here, names are converted to TitleCase and
146146
# underscores are removed.
147147
OBJECT_NAME_TO_CLASS_NAME = {
@@ -170,7 +170,7 @@ def write_init_py(pkg_root, path_parts, import_pairs):
170170
# ==================
171171
class PlotlyNode:
172172
"""
173-
Base class that represents a node in the default-schema.json file
173+
Base class that represents a node in the plot-schema.json file
174174
"""
175175

176176
# Constructor

plotly/graph_reference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def get_graph_reference():
6868
:return: (dict) The graph reference.
6969
7070
"""
71-
path = os.path.join('package_data', 'default-schema.json')
71+
path = os.path.join('package_data', 'plot-schema.json')
7272
s = resource_string('plotly', path).decode('utf-8')
7373
graph_reference = utils.decode_unicode(_json.loads(s))
7474

setup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import sys
1010
import platform
1111

12+
plotly_js_version = '1.38.2'
13+
1214
exec(open('plotly/version.py').read())
1315

1416
here = os.path.dirname(os.path.abspath(__file__))
@@ -157,13 +159,12 @@ def run(self):
157159
raise ImportError('Schema download must be executed with Python 3')
158160

159161
import urllib.request
160-
import json
161-
with urllib.request.urlopen('https://api.plot.ly/v2/plot-schema?sha1') as response:
162-
with open('plotly/package_data/default-schema.json', 'w') as f:
163-
f.write(json.dumps(json.load(response)['schema'],
164-
indent=4,
165-
sort_keys=True,
166-
separators=(',', ': ')))
162+
url = ('https://raw.githubusercontent.com/plotly/plotly.js/'
163+
'v%s/dist/plot-schema.json' % plotly_js_version)
164+
with urllib.request.urlopen(url) as response:
165+
166+
with open('plotly/package_data/plot-schema.json', 'wb') as f:
167+
f.write(response.read())
167168

168169

169170
setup(name='plotly',

0 commit comments

Comments
 (0)