Skip to content

Commit

Permalink
Remove _env instance attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Conengmo committed Oct 13, 2023
1 parent 9ab63f7 commit 1df8e3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion folium/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ def __init__(
):
super().__init__()
self._name = "Map"
self._env = ENV

self._png_image: Optional[bytes] = None
self.png_enabled = png_enabled
Expand Down
7 changes: 3 additions & 4 deletions folium/raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def __init__(
name=self.tile_name, overlay=overlay, control=control, show=show
)
self._name = "TileLayer"
self._env = ENV

tiles_flat = "".join(tiles.lower().strip().split())
if tiles_flat in {"cloudmade", "mapbox", "mapboxbright", "mapboxcontrolroom"}:
Expand All @@ -133,14 +132,14 @@ def __init__(
"argument. See the documentation of the `TileLayer` class."
)
templates = list(
self._env.list_templates(filter_func=lambda x: x.startswith("tiles/"))
ENV.list_templates(filter_func=lambda x: x.startswith("tiles/"))
)
tile_template = "tiles/" + tiles_flat + "/tiles.txt"
attr_template = "tiles/" + tiles_flat + "/attr.txt"

if tile_template in templates and attr_template in templates:
self.tiles = self._env.get_template(tile_template).render()
attr = self._env.get_template(attr_template).render()
self.tiles = ENV.get_template(tile_template).render()
attr = ENV.get_template(attr_template).render()
else:
self.tiles = tiles
if not attr:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import folium
from folium import TileLayer
from folium.features import Choropleth, GeoJson
from folium.folium import ENV

rootpath = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -120,8 +121,8 @@ def test_builtin_tile(self):
tiles = "".join(tiles.lower().strip().split())
url = "tiles/{}/tiles.txt".format
attr = "tiles/{}/attr.txt".format
url = m._env.get_template(url(tiles)).render()
attr = m._env.get_template(attr(tiles)).render()
url = ENV.get_template(url(tiles)).render()
attr = ENV.get_template(attr(tiles)).render()

assert m._children[tiles].tiles == url
assert htmlsafe_json_dumps(attr) in m._parent.render()
Expand Down

0 comments on commit 1df8e3e

Please sign in to comment.