Skip to content

Fix warnings #446

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

Merged
merged 1 commit into from
Jun 10, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 20 additions & 20 deletions folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def render(self, **kwargs):
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://cdnjs.cloudflare.com/ajax/libs/leaflet-dvf/0.2/leaflet-dvf.markers.min.js"), # noqa
name='dvf_js')

Expand Down Expand Up @@ -213,19 +213,19 @@ def render(self, **kwargs):
"""Renders the HTML representation of the element."""
self.json = json.dumps(self.data)

self._parent.html.add_children(Element(Template("""
self._parent.html.add_child(Element(Template("""
<div id="{{this.get_name()}}"></div>
""").render(this=self, kwargs=kwargs)), name=self.get_name())

self._parent.script.add_children(Element(Template("""
self._parent.script.add_child(Element(Template("""
vega_parse({{this.json}},{{this.get_name()}});
""").render(this=self)), name=self.get_name())

figure = self.get_root()
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")

figure.header.add_children(Element(Template("""
figure.header.add_child(Element(Template("""
<style> #{{this.get_name()}} {
position : {{this.position}};
width : {{this.width[0]}}{{this.width[1]}};
Expand All @@ -235,19 +235,19 @@ def render(self, **kwargs):
</style>
""").render(this=self, **kwargs)), name=self.get_name())

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"), # noqa
name='d3')

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://cdnjs.cloudflare.com/ajax/libs/vega/1.4.3/vega.min.js"), # noqa
name='vega')

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://code.jquery.com/jquery-2.1.0.min.js"),
name='jquery')

figure.script.add_children(
figure.script.add_child(
Template("""function vega_parse(spec, div) {
vg.parse.spec(spec, function(chart) { chart({el:div}).update(); });}"""), # noqa
name='vega_parse')
Expand Down Expand Up @@ -499,7 +499,7 @@ def render(self, **kwargs):
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.9/topojson.min.js"), # noqa
name='topojson')

Expand Down Expand Up @@ -536,7 +536,7 @@ def _get_self_bounds(self):

class MarkerCluster(Layer):
"""Creates a MarkerCluster element to append into a map with
Map.add_children.
Map.add_child.

Parameters
----------
Expand Down Expand Up @@ -565,19 +565,19 @@ def render(self, **kwargs):
figure = self.get_root()
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")
figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster-src.js"), # noqa
name='marker_cluster_src')

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js"), # noqa
name='marker_cluster')

figure.header.add_children(
figure.header.add_child(
CssLink("https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css"), # noqa
name='marker_cluster_css')

figure.header.add_children(
figure.header.add_child(
CssLink("https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css"), # noqa
name="marker_cluster_default_css")

Expand Down Expand Up @@ -740,7 +740,7 @@ def __init__(self, popup=None):
class PolyLine(MacroElement):
"""
Creates a PolyLine object to append into a map with
Map.add_children.
Map.add_child.

Parameters
----------
Expand All @@ -767,9 +767,9 @@ def __init__(self, locations, color=None, weight=None,
self.weight = weight
self.opacity = opacity
if isinstance(popup, text_type) or isinstance(popup, binary_type):
self.add_children(Popup(popup))
self.add_child(Popup(popup))
elif popup is not None:
self.add_children(popup)
self.add_child(popup)

self._template = Template(u"""
{% macro script(this, kwargs) %}
Expand Down Expand Up @@ -806,7 +806,7 @@ def _get_self_bounds(self):
class MultiPolyLine(MacroElement):
"""
Creates a MultiPolyLine object to append into a map with
Map.add_children.
Map.add_child.

Parameters
----------
Expand All @@ -833,9 +833,9 @@ def __init__(self, locations, color=None, weight=None,
self.weight = weight
self.opacity = opacity
if isinstance(popup, text_type) or isinstance(popup, binary_type):
self.add_children(Popup(popup))
self.add_child(Popup(popup))
elif popup is not None:
self.add_children(popup)
self.add_child(popup)

self._template = Template(u"""
{% macro script(this, kwargs) %}
Expand Down
52 changes: 26 additions & 26 deletions folium/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def add_wms_layer(self, wms_name=None, wms_url=None, wms_format=None,
wms = WmsTileLayer(wms_url, name=wms_name, format=wms_format,
layers=wms_layers, transparent=wms_transparent,
attr=None)
self.add_children(wms, name=wms_name)
self.add_child(wms, name=wms_name)

def simple_marker(self, location=None, popup=None,
marker_color='blue', marker_icon='info-sign',
Expand Down Expand Up @@ -203,7 +203,7 @@ def simple_marker(self, location=None, popup=None,
icon=Icon(color=marker_color,
icon=marker_icon,
angle=icon_angle))
self.add_children(marker)
self.add_child(marker)

def line(self, locations,
line_color=None, line_opacity=None, line_weight=None,
Expand Down Expand Up @@ -249,9 +249,9 @@ def line(self, locations,
)

if popup is not None:
p.add_children(Popup(popup, max_width=popup_width))
p.add_child(Popup(popup, max_width=popup_width))

self.add_children(p)
self.add_child(p)

def multiline(self, locations, line_color=None, line_opacity=None,
line_weight=None, popup=None, popup_width=300, latlon=True):
Expand Down Expand Up @@ -303,9 +303,9 @@ def multiline(self, locations, line_color=None, line_opacity=None,
latlon=latlon)

if popup is not None:
p.add_children(Popup(popup, max_width=popup_width))
p.add_child(Popup(popup, max_width=popup_width))

self.add_children(p)
self.add_child(p)

def circle_marker(self, location=None, radius=500, popup=None,
line_color='black', fill_color='black',
Expand Down Expand Up @@ -360,7 +360,7 @@ def circle_marker(self, location=None, radius=500, popup=None,
fill_color=fill_color,
fill_opacity=fill_opacity,
popup=popup_)
self.add_children(marker)
self.add_child(marker)

def polygon_marker(self, location=None, line_color='black', line_opacity=1,
line_weight=2, fill_color='blue', fill_opacity=1,
Expand Down Expand Up @@ -421,14 +421,14 @@ def polygon_marker(self, location=None, line_color='black', line_opacity=1,
number_of_sides=num_sides,
rotation=rotation,
radius=radius)
self.add_children(marker)
self.add_child(marker)

def lat_lng_popover(self):
"""Enable popovers to display Lat and Lon on each click."""
warnings.warn("%s is deprecated. Use %s instead" %
("lat_lng_popover", "add_children(LatLngPopup)"),
FutureWarning, stacklevel=2)
self.add_children(LatLngPopup())
self.add_child(LatLngPopup())

def click_for_marker(self, popup=None):
"""Enable the addition of markers via clicking on the map. The marker
Expand All @@ -448,7 +448,7 @@ def click_for_marker(self, popup=None):
warnings.warn("%s is deprecated. Use %s instead" %
("click_for_marker", "add_children(ClickForMarker)"),
FutureWarning, stacklevel=2)
self.add_children(ClickForMarker(popup=popup))
self.add_child(ClickForMarker(popup=popup))

def fit_bounds(self, bounds, padding_top_left=None,
padding_bottom_right=None, padding=None, max_zoom=None):
Expand Down Expand Up @@ -476,13 +476,13 @@ def fit_bounds(self, bounds, padding_top_left=None,
>>> map.fit_bounds([[52.193636, -2.221575], [52.636878, -1.139759]])

"""
self.add_children(FitBounds(bounds,
padding_top_left=padding_top_left,
padding_bottom_right=padding_bottom_right,
padding=padding,
max_zoom=max_zoom,
)
)
self.add_child(FitBounds(bounds,
padding_top_left=padding_top_left,
padding_bottom_right=padding_bottom_right,
padding=padding,
max_zoom=max_zoom,
)
)

def add_plugin(self, plugin):
"""Adds a plugin to the map.
Expand All @@ -496,7 +496,7 @@ def add_plugin(self, plugin):
warnings.warn("%s is deprecated. Use %s instead" %
("add_plugin", "add_children"),
FutureWarning, stacklevel=2)
self.add_children(plugin)
self.add_child(plugin)

def geo_json(self, *args, **kwargs):
"""This method is deprecated and will be removed in v0.2.1. See
Expand Down Expand Up @@ -690,7 +690,7 @@ def style_function(x):
style_function=style_function,
smooth_factor=smooth_factor)

self.add_children(geo_json)
self.add_child(geo_json)

# Create ColorMap.
if color_domain:
Expand All @@ -701,7 +701,7 @@ def style_function(x):
vmin=color_domain[0],
vmax=color_domain[-1],
)
self.add_children(color_scale)
self.add_child(color_scale)

def image_overlay(self, data, opacity=0.25, min_lat=-90.0, max_lat=90.0,
min_lon=-180.0, max_lon=180.0, origin='upper',
Expand Down Expand Up @@ -782,9 +782,9 @@ def image_overlay(self, data, opacity=0.25, min_lat=-90.0, max_lat=90.0,
open(filename, 'wb').write(image)
data = filename

self.add_children(ImageOverlay(data, [[min_lat, min_lon],
[max_lat, max_lon]],
opacity=opacity,
origin=origin,
colormap=colormap,
mercator_project=mercator_project))
self.add_child(ImageOverlay(data, [[min_lat, min_lon],
[max_lat, max_lon]],
opacity=opacity,
origin=origin,
colormap=colormap,
mercator_project=mercator_project))
24 changes: 12 additions & 12 deletions folium/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(self, location=None, width='100%', height='100%',
self.location = location
self.zoom_start = zoom_start

Figure().add_children(self)
Figure().add_child(self)

# Map Size Parameters.
self.width = _parse_size(width)
Expand Down Expand Up @@ -233,7 +233,7 @@ def add_tile_layer(self, tiles='OpenStreetMap', name=None,
min_zoom=min_zoom, max_zoom=max_zoom,
attr=attr, API_key=API_key,
detect_retina=detect_retina)
self.add_children(tile_layer, name=tile_layer.tile_name)
self.add_child(tile_layer, name=tile_layer.tile_name)

def render(self, **kwargs):
"""Renders the HTML representation of the element."""
Expand All @@ -243,13 +243,13 @@ def render(self, **kwargs):

# Import Javascripts
for name, url in _default_js:
figure.header.add_children(JavascriptLink(url), name=name)
figure.header.add_child(JavascriptLink(url), name=name)

# Import Css
for name, url in _default_css:
figure.header.add_children(CssLink(url), name=name)
figure.header.add_child(CssLink(url), name=name)

figure.header.add_children(Element(
figure.header.add_child(Element(
'<style>html, body {'
'width: 100%;'
'height: 100%;'
Expand All @@ -258,7 +258,7 @@ def render(self, **kwargs):
'}'
'</style>'), name='css_style')

figure.header.add_children(Element(
figure.header.add_child(Element(
'<style>#map {'
'position:absolute;'
'top:0;'
Expand Down Expand Up @@ -537,11 +537,11 @@ def __init__(self, location, popup=None, icon=None):
self._name = 'Marker'
self.location = location
if icon is not None:
self.add_children(icon)
self.add_child(icon)
if isinstance(popup, text_type) or isinstance(popup, binary_type):
self.add_children(Popup(popup))
self.add_child(Popup(popup))
elif popup is not None:
self.add_children(popup)
self.add_child(popup)

self._template = Template(u"""
{% macro script(this, kwargs) %}
Expand Down Expand Up @@ -586,9 +586,9 @@ def __init__(self, html=None, max_width=300):
self.script._parent = self

if isinstance(html, Element):
self.html.add_children(html)
self.html.add_child(html)
elif isinstance(html, text_type) or isinstance(html, binary_type):
self.html.add_children(Html(text_type(html)))
self.html.add_child(Html(text_type(html)))

self.max_width = max_width

Expand Down Expand Up @@ -616,7 +616,7 @@ def render(self, **kwargs):
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")

figure.script.add_children(Element(
figure.script.add_child(Element(
self._template.render(this=self, kwargs=kwargs)),
name=self.get_name())

Expand Down
2 changes: 1 addition & 1 deletion folium/plugins/boat_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def render(self, **kwargs):
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://thomasbrueggemann.github.io/leaflet.boatmarker/js/leaflet.boatmarker.min.js"), # noqa
name='markerclusterjs')
4 changes: 2 additions & 2 deletions folium/plugins/fullscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def render(self, **kwargs):
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")

figure.header.add_children(
figure.header.add_child(
JavascriptLink(
"https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.2/Control.FullScreen.min.js"), # noqa
name='Control.Fullscreen.js'
)

figure.header.add_children(
figure.header.add_child(
CssLink("https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.2/Control.FullScreen.min.css"), # noqa
name='Control.FullScreen.css'
)
2 changes: 1 addition & 1 deletion folium/plugins/heat_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def render(self, **kwargs):
assert isinstance(figure, Figure), ("You cannot render this Element "
"if it's not in a Figure.")

figure.header.add_children(
figure.header.add_child(
JavascriptLink("https://leaflet.github.io/Leaflet.heat/dist/leaflet-heat.js"), # noqa
name='leaflet-heat.js')

Expand Down
Loading