|
4 | 4 | """
|
5 | 5 | from __future__ import absolute_import
|
6 | 6 |
|
7 |
| -import hashlib |
8 | 7 | import os
|
9 | 8 | import re
|
10 | 9 | from pkg_resources import resource_string
|
11 | 10 |
|
12 | 11 | import six
|
13 | 12 | from requests.compat import json as _json
|
14 | 13 |
|
15 |
| -from plotly import exceptions, files, utils |
16 |
| -from plotly.api import v2 |
17 |
| - |
18 |
| -GRAPH_REFERENCE_DOWNLOAD_TIMEOUT = 5 # seconds |
| 14 | +from plotly import utils |
19 | 15 |
|
20 | 16 |
|
21 | 17 | # For backwards compat, we keep this list of previously known objects.
|
|
65 | 61 |
|
66 | 62 | def get_graph_reference():
|
67 | 63 | """
|
68 |
| - Attempts to load local copy of graph reference or makes GET request if DNE. |
| 64 | + Load graph reference JSON (aka plot-schema) |
69 | 65 |
|
70 | 66 | :return: (dict) The graph reference.
|
71 |
| - :raises: (PlotlyError) When graph reference DNE and GET request fails. |
72 | 67 |
|
73 | 68 | """
|
74 |
| - if files.check_file_permissions(): |
75 |
| - graph_reference = utils.load_json_dict(files.GRAPH_REFERENCE_FILE) |
76 |
| - else: |
77 |
| - graph_reference = {} |
78 |
| - |
79 |
| - sha1 = hashlib.sha1(six.b(str(graph_reference))).hexdigest() |
80 |
| - |
81 |
| - try: |
82 |
| - response = v2.plot_schema.retrieve( |
83 |
| - sha1, timeout=GRAPH_REFERENCE_DOWNLOAD_TIMEOUT |
84 |
| - ) |
85 |
| - except exceptions.PlotlyRequestError: |
86 |
| - if not graph_reference: |
87 |
| - path = os.path.join('graph_reference', 'default-schema.json') |
88 |
| - s = resource_string('plotly', path).decode('utf-8') |
89 |
| - graph_reference = _json.loads(s) |
90 |
| - else: |
91 |
| - data = response.json() |
92 |
| - if data['modified']: |
93 |
| - graph_reference = data['schema'] |
| 69 | + path = os.path.join('graph_reference', 'default-schema.json') |
| 70 | + s = resource_string('plotly', path).decode('utf-8') |
| 71 | + graph_reference = _json.loads(s) |
94 | 72 |
|
95 | 73 | return utils.decode_unicode(graph_reference)
|
96 | 74 |
|
|
0 commit comments