-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPythonCaller.py
70 lines (57 loc) · 2.88 KB
/
PythonCaller.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
63
64
65
66
67
68
69
70
# This is the default setup for PythonCaller
import fme
import fmeobjects
class FeatureProcessor(object):
"""Template Class Interface:
When using this class, make sure its name is set as the value of the 'Class
to Process Features' transformer parameter.
"""
def __init__(self):
"""Base constructor for class members."""
pass
def input(self, feature):
"""This method is called for each FME Feature entering the
PythonCaller. If knowledge of all input Features is not required for
processing, then the processed Feature can be emitted from this method
through self.pyoutput(). Otherwise, the input FME Feature should be
cached to a list class member and processed in process_group() when
'Group by' attributes(s) are specified, or the close() method.
:param fmeobjects.FMEFeature feature: FME Feature entering the
transformer.
"""
self.pyoutput(feature)
def close(self):
"""This method is called once all the FME Features have been processed
from input().
"""
pass
def process_group(self):
"""When 'Group By' attribute(s) are specified, this method is called
once all the FME Features in a current group have been sent to input().
FME Features sent to input() should generally be cached for group-by
processing in this method when knowledge of all Features is required.
The resulting Feature(s) from the group-by processing should be emitted
through self.pyoutput().
FME will continue calling input() a number of times followed
by process_group() for each 'Group By' attribute, so this
implementation should reset any class members for the next group.
"""
pass
def has_support_for(self, support_type):
"""This method returns whether this PythonCaller supports a certain type.
The only supported type is fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM.
:param int support_type: The support type being queried.
:returns: True if the passed in support type is supported.
:rtype: bool
"""
if support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM:
# If this is set to return True, FME will pass features to the input() method that
# come from a feature table object. This allows for significant performance gains
# when processing large numbers of features.
# To enable this, the following conditions must be met:
# 1) features passed into the input() method cannot be copied or cached for later use
# 2) features cannot be read or modified after being passed to self.pyoutput()
# 3) Group Processing must not be enabled
# Violations will cause undefined behavior.
return False
return False