-
Notifications
You must be signed in to change notification settings - Fork 432
/
pipeline_xml.py
62 lines (40 loc) · 1.27 KB
/
pipeline_xml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from xml.etree import ElementTree
import pdal
class XMLElement(object):
def __init__(self):
self.source = None
def xml(self):
element = ElementTree.Element(self.tag, self.attrib)
if self.source:
try:
sources = iter(self.source)
except TypeError:
sources = [self.source]
for source in sources:
element.append(source.xml())
return element
class Pipeline(XMLElement):
tag = 'Pipeline'
def __init__(self, customversion=None):
super(Pipeline, self).__init__()
self.attrib = {'version': customversion or pdal.__version__}
def xml(self):
element = super(Pipeline, self).xml()
return ElementTree.ElementTree(element)
class PipelineComponent(XMLElement):
def __init__(self, drivertype):
super(PipelineComponent, self).__init__()
self.attrib = {'type': self.typeformat % drivertype}
class Stage(PipelineComponent):
pass
class Reader(Stage):
tag = 'Reader'
typeformat = 'readers.%s'
class Filter(Stage):
tag = 'Filter'
typeformat = 'filters.%s'
class MultiFilter(Filter):
tag = 'MultiFilter'
class Writer(PipelineComponent):
tag = 'Writer'
typeformat = 'writers.%s'