Debian Codegraph @

examples/simple_example.py

raw symbols SCIP
1 #!/usr/bin/env python
2 import pathlib
3
4 from fastkml import kml
5
6
7 def print_child_features(element, depth=0):
8 """Prints the name of every child node of the given element, recursively."""
9 if not getattr(element, "features", None):
10 return
11 for feature in element.features:
12 print(" " * depth, feature.name)
13 print_child_features(feature, depth + 1)
14
15
16 if __name__ == "__main__":
17 examples_dir = pathlib.Path(__file__).parent
18 fname = pathlib.Path(examples_dir / "KML_Samples.kml")
19
20 k = kml.KML.parse(fname)
21
22 print_child_features(k)