Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_options():
assert parse_options(thing=42) == {'thing': 42}
assert parse_options(thing=None) == {}
assert parse_options(long_thing=42) == {'longThing': 42}
assert parse_options(thing=42, lst=[1, 2]) == {'thing': 42, 'lst': [1, 2]}
geom_type='Point', position='topleft', placeholder='Search',
collapsed=False, **kwargs):
super(Search, self).__init__()
assert isinstance(layer,
(GeoJson, MarkerCluster, FeatureGroup, TopoJson)
), 'Search can only index FeatureGroup, ' \
'MarkerCluster, GeoJson, and TopoJson layers at ' \
'this time.'
self.layer = layer
self.search_label = search_label
self.search_zoom = search_zoom
self.geom_type = geom_type
self.position = position
self.placeholder = placeholder
self.collapsed = collapsed
self.options = parse_options(**kwargs)
if 'read' in dir(data):
self.embed = True
self.data = data.read()
elif type(data) is dict:
self.embed = True
self.data = json.dumps(data)
else:
self.embed = False
self.data = data
self.add_last_point = bool(add_last_point)
self.period = period
self.date_options = date_options
self.duration = 'undefined' if duration is None else '"' + duration + '"'
self.options = parse_options(
position='bottomleft',
min_speed=min_speed,
max_speed=max_speed,
auto_play=auto_play,
loop_button=loop_button,
time_slider_drag_update=time_slider_drag_update,
player_options={
'transitionTime': int(transition_time),
'loop': loop,
'startOver': True
},
def __init__(self, width=20, height=20, radius=12, weight=2.0,
color="#3388ff", fill_color="#3388ff",
opacity=0.75, fill_opacity=0.5):
super(CirclePattern, self).__init__()
self._name = 'CirclePattern'
self.options_pattern_circle = parse_options(
x=radius + 2 * weight,
y=radius + 2 * weight,
weight=weight,
radius=radius,
color=color,
fill_color=fill_color,
opacity=opacity,
fill_opacity=fill_opacity,
fill=True,
)
self.options_pattern = parse_options(
width=width,
height=height,
)
self.parent_map = None
def __init__(self, position='topright', primary_length_unit='meters',
secondary_length_unit='miles', primary_area_unit='sqmeters',
secondary_area_unit='acres', **kwargs):
super(MeasureControl, self).__init__()
self._name = 'MeasureControl'
self.options = parse_options(
position=position,
primary_length_unit=primary_length_unit,
secondary_length_unit=secondary_length_unit,
primary_area_unit=primary_area_unit,
secondary_area_unit=secondary_area_unit,
**kwargs
)
def __init__(self, data, transition_time=200, loop=False, auto_play=False,
period='P1D', time_interval=False, name=None,
overlay=True, control=True, show=True):
super(TimestampedWmsTileLayers, self).__init__(name=name,
overlay=overlay,
control=control,
show=show)
self._name = 'TimestampedWmsTileLayers'
self.options = parse_options(
period=period,
time_interval=time_interval,
)
self.options_control = parse_options(
position='bottomleft',
auto_play=auto_play,
player_options={
'transitionTime': int(transition_time),
'loop': loop,
},
)
if isinstance(data, WmsTileLayer):
self.layers = [data]
else:
self.layers = data # Assume iterable
def __init__(self, html=None, icon_size=None, icon_anchor=None,
popup_anchor=None, class_name='empty'):
super(DivIcon, self).__init__()
self._name = 'DivIcon'
self.options = parse_options(
html=html,
icon_size=icon_size,
icon_anchor=icon_anchor,
popup_anchor=popup_anchor,
class_name=class_name,
)
def __init__(self, **kwargs):
super(LocateControl, self).__init__()
self._name = 'LocateControl'
self.options = parse_options(**kwargs)
def __init__(self, icon_image, icon_size=None, icon_anchor=None,
shadow_image=None, shadow_size=None, shadow_anchor=None,
popup_anchor=None):
super(Icon, self).__init__()
self._name = 'CustomIcon'
self.options = parse_options(
icon_url=image_to_url(icon_image),
icon_size=icon_size,
icon_anchor=icon_anchor,
shadow_url=shadow_image and image_to_url(shadow_image),
shadow_size=shadow_size,
shadow_anchor=shadow_anchor,
popup_anchor=popup_anchor,
)
def __init__(self, position='bottomright', separator=' : ',
empty_string='Unavailable', lng_first=False, num_digits=5,
prefix='', lat_formatter=None, lng_formatter=None, **kwargs):
super(MousePosition, self).__init__()
self._name = 'MousePosition'
self.options = parse_options(
position=position,
separator=separator,
empty_string=empty_string,
lng_first=lng_first,
num_digits=num_digits,
prefix=prefix,
**kwargs
)
self.lat_formatter = lat_formatter or 'undefined'
self.lng_formatter = lng_formatter or 'undefined'