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_zip_path():
assert fiona.listlayers('zip://tests/data/coutwildrnp.zip') == ['coutwildrnp']
def test_directory_trailing_slash():
assert fiona.listlayers('tests/data/') == ['coutwildrnp', 'gre']
def test_layer_index():
layer = fiona.listlayers(DATA).index('polygons')
assert list(read_features(DATA, layer=layer)) == target_features
def test_path_ioerror(self):
self.assertRaises(IOError, fiona.listlayers, ("foobar"))
def test_zip_path_arch():
assert fiona.listlayers('/coutwildrnp.shp', vfs='zip://tests/data/coutwildrnp.zip') == ['coutwildrnp']
create_sample_data(filename, "GPKG", layer="layer2")
create_sample_data(filename, "GPKG", layer="layer3")
create_sample_data(filename, "GPKG", layer="layer4")
assert fiona.listlayers(filename) == ["layer1", "layer2", "layer3", "layer4"]
# remove by index
fiona.remove(filename, layer=2)
assert fiona.listlayers(filename) == ["layer1", "layer2", "layer4"]
# remove by name
fiona.remove(filename, layer="layer2")
assert fiona.listlayers(filename) == ["layer1", "layer4"]
# remove by negative index
fiona.remove(filename, layer=-1)
assert fiona.listlayers(filename) == ["layer1"]
# invalid layer name
with pytest.raises(ValueError):
fiona.remove(filename, layer="invalid_layer_name")
# invalid layer index
with pytest.raises(DatasetDeleteError):
fiona.remove(filename, layer=999)
def test_single_file():
assert fiona.listlayers('tests/data/coutwildrnp.shp') == ['coutwildrnp']
]
Returns
-------
list
A list of tuples where the first element of each tuple is the datasource
and the second is a list of layers to render.
"""
output = []
for ds_layers in value:
_split = ds_layers.split(',')
ds = _split[0]
layers = _split[1:]
if ds != '-' and (len(layers) is 0 or '%all' in layers):
layers = fio.listlayers(ds)
elif ds == '-':
layers = [None]
output.append((ds, layers))
return output
def load(self):
try:
self.layers = fiona.listlayers(self.filename)
except (ValueError, IOError):
driver = guess_driver(self.filename)
self.meta = {'driver': driver}
self.empty_file = True