Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def substitute_layer(self, old, new):
if isinstance(new, dict):
new = basemap_to_tiles(new)
if old.model_id not in self._layer_ids:
raise LayerException('Could not substitute layer: layer not in layergroup.')
self.layers = tuple([new if l.model_id == old.model_id else l for l in self.layers])
def _validate_layers(self, proposal):
'''Validate layers list.
Makes sure only one instance of any given layer can exist in the
layers list.
'''
self._layer_ids = [l.model_id for l in proposal.value]
if len(set(self._layer_ids)) != len(self._layer_ids):
raise LayerException('duplicate layer detected, only use each layer once')
return proposal.value
def remove_layer(self, layer):
if layer.model_id not in self._layer_ids:
raise LayerException('layer not on in layergroup: %r' % layer)
self.layers = tuple([l for l in self.layers if l.model_id != layer.model_id])
def substitute_layer(self, old, new):
if isinstance(new, dict):
new = basemap_to_tiles(new)
if old.model_id not in self._layer_ids:
raise LayerException('Could not substitute layer: layer not on map.')
self.layers = tuple([new if l.model_id == old.model_id else l for l in self.layers])
def add_layer(self, layer):
if isinstance(layer, dict):
layer = basemap_to_tiles(layer)
if layer.model_id in self._layer_ids:
raise LayerException('layer already on map: %r' % layer)
self.layers = tuple([l for l in self.layers] + [layer])
def remove_layer(self, layer):
if layer.model_id not in self._layer_ids:
raise LayerException('layer not on map: %r' % layer)
self.layers = tuple([l for l in self.layers if l.model_id != layer.model_id])