Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the JsCode object from the js_loader package #2081

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
--file requirements.txt
--file requirements-dev.txt

- name: Install folium from source
run: python -m pip install js_loader

- name: Install folium from source
run: python -m pip install -e . --no-deps --force-reinstall

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ jobs:
- name: Install folium from source
run: python -m pip install -e . --no-deps --force-reinstall

- name: Install js_loader
run: python -m pip install js_loader

- name: Code tests
run: python -m pytest -vv --ignore=tests/selenium
4 changes: 4 additions & 0 deletions .github/workflows/test_latest_branca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
shell: bash -l {0}
run: python -m pip install -e . --no-deps --force-reinstall

- name: Install js_loader
shell: bash -l {0}
run: python -m pip install js_loader

- name: Tests with latest branca
shell: bash -l {0}
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test_mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
run: |
python -m pip install -e . --no-deps --force-reinstall

- name: Install js_loader
shell: bash -l {0}
run: |
python -m pip install js_loader

- name: Mypy test
shell: bash -l {0}
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_selenium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
shell: bash -l {0}
run: python -m pip install -e . --no-deps --force-reinstall

- name: Install js_loader
shell: bash -l {0}
run: python -m pip install js_loader

- name: Selenium tests
shell: bash -l {0}
run: python -m pytest tests/selenium -vv
14 changes: 1 addition & 13 deletions folium/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
none_min,
write_png,
)
from js_loader import JsCode # noqa: F401

try:
import pandas as pd
Expand Down Expand Up @@ -436,19 +437,6 @@ def get_and_assert_figure_root(obj: Element) -> Figure:
return figure


class JsCode:
"""Wrapper around Javascript code."""

def __init__(self, js_code: Union[str, "JsCode"]):
if isinstance(js_code, JsCode):
self.js_code: str = js_code.js_code
else:
self.js_code = js_code

def __str__(self):
return self.js_code


def parse_font_size(value: Union[str, int, float]) -> str:
"""Parse a font size value, if number set as px"""
if isinstance(value, (int, float)):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def walk_subpkg(name):
with open("requirements.txt") as f:
tests_require = f.readlines()
install_requires = [t.strip() for t in tests_require]
install_requires.append("js_loader")

setup(
name="folium",
Expand Down
Loading