Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Jenselme/find-all
Add a way to find all layers matching an attribute
- Loading branch information
Showing
4 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import mappyfile | ||
|
||
# load will accept a filename (loads will accept a string) | ||
mapfile = mappyfile.load("./docs/examples/raster.map") | ||
|
||
# Search of a layer by its name | ||
mappyfile.find(mapfile['layers'], 'name', 'my_layer') | ||
|
||
# Search for all layers of a group | ||
for layer in mappyfile.findall(mapfile['layers'], 'group', 'my_group'): | ||
print(layer['name']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# allow high-level functions to be accessed directly from the mappyfile module | ||
from mappyfile.utils import load, loads, find, dumps, write | ||
from mappyfile.utils import load, loads, find, findall, dumps, write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters