8
8
import codecs
9
9
from jinja2 import Environment , FileSystemLoader
10
10
import pyecharts .constants as constants
11
- import json
11
+ from pyecharts . utils import get_resource_dir
12
12
13
13
14
- def get_resource_dir (folder ):
15
- """
16
-
17
- :param folder:
18
- :return:
19
- """
20
- current_path = os .path .dirname (__file__ )
21
- resource_path = os .path .join (current_path , folder )
22
- return resource_path
23
-
24
-
25
- #with codecs.open(os.path.join(get_resource_dir('templates'), 'js', 'echarts', 'registry.json'), 'r', 'utf-8') as f:
26
- with open (os .path .join (get_resource_dir ('templates' ), 'js' , 'echarts' , 'registry.json' ), 'rb' ) as f :
27
- content = f .read ().decode ('utf-8' )
28
- CONFIG = json .loads (content )
29
-
30
- DEFAULT_JS_LIBRARIES = CONFIG ['FILE_MAP' ]
31
-
32
- CITY_NAME_PINYIN_MAP = CONFIG ['PINYIN_MAP' ]
33
-
34
14
PY2 = sys .version_info [0 ] == 2
35
15
36
16
JS_PATTERN = re .compile (r'<!-- build -->(.*)<!-- endbuild -->' ,
@@ -107,7 +87,7 @@ def produce_require_configuration(dependencies, jshost):
107
87
require_conf_items = [
108
88
"'%s': '%s/%s'" % (key ,
109
89
jshost ,
110
- DEFAULT_JS_LIBRARIES .get (key , key ))
90
+ constants . DEFAULT_JS_LIBRARIES .get (key , key ))
111
91
for key in _d ]
112
92
require_libraries = ["'%s'" % key for key in _d ]
113
93
return dict (
@@ -124,7 +104,7 @@ def produce_html_script_list(dependencies):
124
104
"""
125
105
_d = ensure_echarts_is_in_the_front (dependencies )
126
106
script_list = [
127
- '%s' % DEFAULT_JS_LIBRARIES .get (key , key )
107
+ '%s' % constants . DEFAULT_JS_LIBRARIES .get (key , key )
128
108
for key in _d ]
129
109
return script_list
130
110
0 commit comments