Skip to content

Commit

Permalink
upgrade to lml 0.0.6 and optionally search pyecharts_snapshot (pyecha…
Browse files Browse the repository at this point in the history
…rts#835)

* 🐛 optionally search for pyechart_snapshot. fix pyecharts#815 and fix pyecharts#827

* 🐛 fix the typo in lml search regex and adopt flake 3.6 syntax

* 🔨 update travis file

* 🔨 update travis file

* 💚 update jupyter-echarts-pypkg to 0.1.3 which lifts lml version to 0.0.6

* 💚 fix windows build problems. updated all relevant pypkgs for testing

* 💚 0.1.3 was removed because it won't work pyecharts 0.5.11

* 🔨 code refactoring and addressing review comments
  • Loading branch information
chfw authored Nov 12, 2018
1 parent 6fed780 commit 6617cb9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ before_install:
- pip install -r test/requirements.txt
script:
- python setup.py install
- make tests
- make
after_success:
- cd test
- codecov
cd test && codecov

16 changes: 9 additions & 7 deletions pyecharts/js_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import json
import os

from lml.loader import scan_plugins
from lml.loader import scan_plugins_regex
from lml.plugin import PluginManager

import pyecharts.exceptions as exceptions

# here are all plugins from pyecharts team
OFFICIAL_PLUGINS = ["jupyter_echarts_pypkg", "pyecharts_snapshot"]
THIRD_PARTY_PLUGIN_PREFIX = "echarts_"
MUST_LOAD_PLUGINS = ["jupyter_echarts_pypkg"]
PYTHON_PLUGINS = "^pyecharts_.+$"
JS_PLUGINS = "^echarts_.+$"
OPTIONAL_PLUGIN_PREFIX = "|".join([PYTHON_PLUGINS, JS_PLUGINS])

JS_EXTENSION_PLUGIN_TYPE = "pyecharts_js_extension"
JS_EXTENSION_REGISTRY = "registry.json"
Expand Down Expand Up @@ -115,10 +117,10 @@ def get_a_extension(self, name):

EXTENSION_MANAGER = JsExtensionManager()
# Load js & map file index into a dictionary.
scan_plugins(
THIRD_PARTY_PLUGIN_PREFIX,
"pyecharts", # <- useful for pyinstaller only
white_list=OFFICIAL_PLUGINS,
scan_plugins_regex(
plugin_name_patterns=OPTIONAL_PLUGIN_PREFIX,
pyinstaller_path="pyecharts", # <- useful for pyinstaller only
white_list=MUST_LOAD_PLUGINS,
)


Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jinja2>=2.8
future
lml>=0.0.2
jupyter-echarts-pypkg>=0.1.1
lml>=0.0.6
jupyter-echarts-pypkg>=0.1.4
javascripthon>=0.10; python_version>"3.4"
requests; python_version<"3.5"
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
__requires__ = [
"jinja2",
"future",
"jupyter-echarts-pypkg==0.1.2",
"lml==0.0.2",
"jupyter-echarts-pypkg==0.1.4",
"lml==0.0.6",
"requests",
'javascripthon>=0.10; python_version>"3.4"',
'requests; python_version<"3.5"',
Expand Down
2 changes: 1 addition & 1 deletion test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pillow
mock;python_version<"3"
echarts-countries-pypkg
echarts-china-cities-pypkg
echarts-china-provinces-pypkg
echarts-china-provinces-pypkg>=0.0.3
12 changes: 6 additions & 6 deletions test/test_template_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def test_echarts_js_dependencies():
bar = create_demo_bar()
html = tpl.render(bar=bar)
assert (
'<script type="text/javascript" src="http://localhost/echarts/echarts.min.js"></script>'
'<script type="text/javascript" src="http://localhost/echarts/echarts.min.js"></script>' # noqa: E501
== html
) # flake8: noqa
)


def test_echarts_js_dependencies_embed():
Expand Down Expand Up @@ -65,23 +65,23 @@ def test_echarts_js_container():
assert (
'<div id="id_demo_chart" style="width:800px;height:400px;"></div>'
== html
) # flake8: noqa
)

bar.width = 1024
bar.height = 768
html = tpl.render(bar=bar)
assert (
'<div id="id_demo_chart" style="width:1024px;height:768px;"></div>'
== html
) # flake8: noqa
)

bar.width = "1024px"
bar.height = "768px"
html = tpl.render(bar=bar)
assert (
'<div id="id_demo_chart" style="width:1024px;height:768px;"></div>'
== html
) # flake8: noqa
)


def test_echarts_js_content():
Expand All @@ -100,7 +100,7 @@ def test_echarts_js_content_wrap():

@raises(TypeError)
def test_create_environment_without_config():
be = BaseEnvironment()
BaseEnvironment()


def test_echarts_js_in_first():
Expand Down

0 comments on commit 6617cb9

Please sign in to comment.