-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListKeyValuePairExtractor.fmx
390 lines (380 loc) · 97.6 KB
/
ListKeyValuePairExtractor.fmx
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
#! <?xml version="1.0" encoding="UTF-8" ?>
#! <TRANSFORMER
# TRANSFORMER_BEGIN ListKeyValuePairExtractor,1,Attributes,a24b75d4-9945-11e7-8bb9-c42c033923d4,"Linked Always",No,NO_PARALLELISM,,No,17291,YES,No,2or3
# <p>The <em>ListKeyValuePairExtractor</em> creates new attributes based on a list of keys (attribute names) and a list of values. <br />
# For example, a feature might contain the following list elements:</p>
# <p><em>list{0}.name = 'StringData'</em><br />
# <em>list{0}.data = 'Test Value'</em> <br />
# <em>list{1}.name = 'IntData'</em><br />
# <em>list{1}.data = 32536</em> <br />
# <em>list{2}.name = 'FloatData'</em><br />
# <em>list{2}.data = 23.67</em></p>
# <p>If the user sets the <em>Attribute Name List</em> to <em>list{<strong>n</strong>}.name</em> and the <em>Attribute Value List</em> to <em>list{<strong>n</strong>}.data</em>, the transformer will add the following attributes to the output feature:</p>
# <p><em>StringData = 'Test Value'</em><br />
# <em>IntData = 32536</em><br />
# <em>FloatData = 23.67</em></p>
# <h3>IMPORTANT</h3>
# <p>In the example above, you can fill in any integer for list element <strong>n</strong>. Due to the fact that FME does not support nested lists as an input parameter for custom transformers, you will actually have to specify it as a list attribute, using FME's List Element Selection dialog.<br />
# This means you can select regular attributes for the <em>Attribute Name List</em> and <em>Attribute Value List</em> parameters, but that will result in an error. It also means that if you have a basic unnested list, the index you specify does not matter. The <em>ListKeyValuePairExtractor</em> will simply fetch the complete list.</p>
# <p>For example, if you want to use all the values in <em>list{}.name</em> as your <em>Attribute Name List</em>, you could set the input parameter to <em>list{<strong>0</strong>}.name</em>. If there are 3 elements in this list, the transformer will fetch <em>list{0}.name</em>, <em>list{1}.name</em> and <em>list{2}.name</em>. But this will also be the case if you set it to <em>list{<strong>2</strong>}.name</em>, for example.</p>
# <p>However, if you want to use all the values of <em>list{}.nestedlist{}</em>, the index of the parent <em>list{}</em> matters and should exist! For example, if you set the <em>Attribute Name List</em> parameter to <em>list{<strong>3</strong>}.nestedlist{0}</em>, only the <em>nestedlist{}</em> elements within <em>list{<strong>3</strong>}</em> will be used. </p>
# <p>Please note that the created attributes will not be exposed. You can use an <a href="https://www.safe.com/transformers/attribute-exposer/">AttributeExposer</a> afterwards to achieve that.</p>
# <h3>Notes</h3>
# <ul>
# <li>This transformer has been tested on Python 2.7 and 3.4. </li>
# <li>Released under <a href="https://github.com/SanderSchaminee/fme-listkeyvaluepairextractor/blob/master/LICENSE">GNU General Public License v3.0</a>. </li>
# <li>If you notice a bug or desire a new feature, please contact me. Or make a <a href="https://github.com/SanderSchaminee/fme-listkeyvaluepairextractor/">pull request</a>!</li>
# </ul>
# TRANSFORMER_END
#! FME_DOCUMENT_GUID="a24b75d4-9945-11e7-8bb9-c42c033923d4"
#! XFORM_DEPRECATED="No"
#! MARKDOWN_USAGE="**Attribute Name List** Specify the list attribute that should be used to extract the attribute names (keys). The list can have missing elements (in which case no attribute will be written), but the list should be in the same order as the _Attribute Value List_. Please read the overview section of this documentation for more information. **Attribute Value List** Specify the list attribute that should be used to extract the attribute values. If a value is missing or null, a warning will be shown in the log. The value list does not need to be of the same size as the _Attribute Name List_, but if the created pairs should match, the list has to be in the same order. Please read the overview section of this documentation for more information. **Conflict Resolution** If one or more of the _Attribute Name List_ elements already exist as a feature attribute, setting this value to "Keep Original Attributes" will prevent the attribute values from being overwritten by the _Attribute Value List_ elements."
#! VIEW_POSITION="-246.002 195.002"
#! WORKSPACE_VERSION="1"
#! MAX_LOOP_ITERATIONS=""
#! ATTR_TYPE_ENCODING="SDF"
#! MARKDOWN_DESCRIPTION="The _ListKeyValuePairExtractor_ creates new attributes based on a list of keys (attribute names) and a list of values. For example, a feature might contain the following list elements: _list{0}.name = 'StringData'_ _list{0}.data = 'Test Value'_ _list{1}.name = 'IntData'_ _list{1}.data = 32536_ _list{2}.name = 'FloatData'_ _list{2}.data = 23.67_ If the user sets the _Attribute Name List_ to _list{**n**}.name_ and the _Attribute Value List_ to _list{**n**}.data_, the transformer will add the following attributes to the output feature: _StringData = 'Test Value'_ _IntData = 32536_ _FloatData = 23.67_ ### IMPORTANT In the example above, you can fill in any integer for list element **n**. Due to the fact that FME does not support nested lists as an input parameter for custom transformers, you will actually have to specify it as a list attribute, using FME's List Element Selection dialog. This means you can select regular attributes for the _Attribute Name List_ and _Attribute Value List_ parameters, but that will result in an error. It also means that if you have a basic unnested list, the index you specify does not matter. The _ListKeyValuePairExtractor_ will simply fetch the complete list. For example, if you want to use all the values in _list{}.name_ as your _Attribute Name List_, you could set the input parameter to _list{**0**}.name_. If there are 3 elements in this list, the transformer will fetch _list{0}.name_, _list{1}.name_ and _list{2}.name_. But this will also be the case if you set it to _list{**2**}.name_, for example. However, if you want to use all the values of _list{}.nestedlist{}_, the index of the parent _list{}_ matters and should exist! For example, if you set the _Attribute Name List_ parameter to _list{**3**}.nestedlist{0}_, only the _nestedlist{}_ elements within _list{**3**}_ will be used. Please note that the created attributes will not be exposed. You can use an [AttributeExposer](https://www.safe.com/transformers/attribute-exposer/) afterwards to achieve that. ### Notes - This transformer has been tested on Python 2.7 and 3.4. - Released under [GNU General Public License v3.0](https://github.com/SanderSchaminee/fme-listkeyvaluepairextractor/blob/master/LICENSE). - If you notice a bug or desire a new feature, please contact me. Or make a [pull request](https://github.com/SanderSchaminee/fme-listkeyvaluepairextractor/)!"
#! FME_PROCESS_GROUPS_ORDERED="No"
#! ZOOM_SCALE="100"
#! ITERATION_COUNT_ATTR=""
#! LAST_SAVE_BUILD="FME(R) 2017.0.1.1 (20170512 - Build 17291 - macosx)"
#! FME_PROCESS_COUNT="NO_PARALLELISM"
#! FME_PROCESS_GROUP_BY=""
#! FME_DOCUMENT_PRIORGUID="f5dff8f8-5b21-11e7-be76-c42c033923d4,add26dd2-5b28-11e7-84ae-c42c033923d4,c74ac394-5b29-11e7-891b-c42c033923d4,1fb8e4de-5b39-11e7-8e59-c42c033923d4,c873fab8-60cb-11e7-bbbd-c42c033923d4"
#! BLOCKED_LOOPING="No"
#! FME_BUILD_NUM="17291"
#! HISTORY="June<space>20<comma><space>2017,Sander<space>Schamin<u00e9>e,Initial<space>creation,July<space>4<comma><space>2017,Sander<space>Schamin<u00e9>e,Improved<space>the<space>Help<space>section<space>a<space>bit,September<space>14<comma><space>2017,Sander<space>Schamin<u00e9>e,Set<space>to<space>Always<space>Linked<comma><space>renamed<space>parameters<comma><space>updated<space>docs"
#! PASSWORD=""
#! DOC_EXTENTS="2094.54 557.003"
#! CATEGORY="Attributes"
#! USAGE="<p><strong>Attribute Name List</strong><br /> Specify the list attribute that should be used to extract the attribute names (keys). The list can have missing elements (in which case no attribute will be written), but the list should be in the same order as the <em>Attribute Value List</em>. Please read the overview section of this documentation for more information.</p> <p><strong>Attribute Value List</strong><br /> Specify the list attribute that should be used to extract the attribute values. If a value is missing or null, a warning will be shown in the log. The value list does not need to be of the same size as the <em>Attribute Name List</em>, but if the created pairs should match, the list has to be in the same order. Please read the overview section of this documentation for more information.</p> <p><strong>Conflict Resolution</strong><br /> If one or more of the <em>Attribute Name List</em> elements already exist as a feature attribute, setting this value to "Keep Original Attributes" will prevent the attribute values from being overwritten by the <em>Attribute Value List</em> elements.</p>"
#! TITLE="ListKeyValuePairExtractor"
#! SHOW_ANNOTATIONS="true"
#! FMX_ATTRIBUTE_PROPOGATION_MODE="AUTO"
#! SHOW_INFO_NODES="true"
#! WARN_INVALID_XFORM_PARAM="Yes"
#! LAST_SAVE_DATE="2017-09-14T14:40:03"
#! EXPLICIT_BOOKMARK_ORDER="false"
#! FME_LINKED_TRANSFORMER_VERSION="1"
#! FME_SERVER_SERVICES=""
#! FMX_INSERT_MODE="Linked Always"
#! DOC_TOP_LEFT="-576.525 -359.001"
#! PYTHON_COMPATIBILITY="2or3"
#! DESCRIPTION="<p>The <em>ListKeyValuePairExtractor</em> creates new attributes based on a list of keys (attribute names) and a list of values. <br /> For example, a feature might contain the following list elements:</p> <p><em>list{0}.name = 'StringData'</em><br /> <em>list{0}.data = 'Test Value'</em> <br /> <em>list{1}.name = 'IntData'</em><br /> <em>list{1}.data = 32536</em> <br /> <em>list{2}.name = 'FloatData'</em><br /> <em>list{2}.data = 23.67</em></p> <p>If the user sets the <em>Attribute Name List</em> to <em>list{<strong>n</strong>}.name</em> and the <em>Attribute Value List</em> to <em>list{<strong>n</strong>}.data</em>, the transformer will add the following attributes to the output feature:</p> <p><em>StringData = 'Test Value'</em><br /> <em>IntData = 32536</em><br /> <em>FloatData = 23.67</em></p> <h3>IMPORTANT</h3> <p>In the example above, you can fill in any integer for list element <strong>n</strong>. Due to the fact that FME does not support nested lists as an input parameter for custom transformers, you will actually have to specify it as a list attribute, using FME's List Element Selection dialog.<br /> This means you can select regular attributes for the <em>Attribute Name List</em> and <em>Attribute Value List</em> parameters, but that will result in an error. It also means that if you have a basic unnested list, the index you specify does not matter. The <em>ListKeyValuePairExtractor</em> will simply fetch the complete list.</p> <p>For example, if you want to use all the values in <em>list{}.name</em> as your <em>Attribute Name List</em>, you could set the input parameter to <em>list{<strong>0</strong>}.name</em>. If there are 3 elements in this list, the transformer will fetch <em>list{0}.name</em>, <em>list{1}.name</em> and <em>list{2}.name</em>. But this will also be the case if you set it to <em>list{<strong>2</strong>}.name</em>, for example.</p> <p>However, if you want to use all the values of <em>list{}.nestedlist{}</em>, the index of the parent <em>list{}</em> matters and should exist! For example, if you set the <em>Attribute Name List</em> parameter to <em>list{<strong>3</strong>}.nestedlist{0}</em>, only the <em>nestedlist{}</em> elements within <em>list{<strong>3</strong>}</em> will be used. </p> <p>Please note that the created attributes will not be exposed. You can use an <a href="https://www.safe.com/transformers/attribute-exposer/">AttributeExposer</a> afterwards to achieve that.</p> <h3>Notes</h3> <ul> <li>This transformer has been tested on Python 2.7 and 3.4. </li> <li>Released under <a href="https://github.com/SanderSchaminee/fme-listkeyvaluepairextractor/blob/master/LICENSE">GNU General Public License v3.0</a>. </li> <li>If you notice a bug or desire a new feature, please contact me. Or make a <a href="https://github.com/SanderSchaminee/fme-listkeyvaluepairextractor/">pull request</a>!</li> </ul>"
#! USE_MARKDOWN="YES"
#! >
#! <DATASETS>
#! </DATASETS>
#! <DATA_TYPES>
#! </DATA_TYPES>
#! <GEOM_TYPES>
#! </GEOM_TYPES>
#! <FEATURE_TYPES>
#! </FEATURE_TYPES>
#! <FMESERVER>
#! </FMESERVER>
#! <GLOBAL_PARAMETERS>
#! <GLOBAL_PARAMETER
#! GUI_LINE="GUI ATTR __KEY_ATTR Attribute Name List:"
#! DEFAULT_VALUE=""
#! IS_STAND_ALONE="false"
#! />
#! <GLOBAL_PARAMETER
#! GUI_LINE="GUI ATTR __VAL_ATTR Attribute Value List:"
#! DEFAULT_VALUE=""
#! IS_STAND_ALONE="false"
#! />
#! <GLOBAL_PARAMETER
#! GUI_LINE="GUI LOOKUP_CHOICE __ATTR_CONFLICT_RES Use<space>Original<space>Attribute<space>Values,0%Use<space>List<space>Attribute<space>Values,1 Conflict Resolution:"
#! DEFAULT_VALUE="1"
#! IS_STAND_ALONE="false"
#! />
#! </GLOBAL_PARAMETERS>
#! <COMMENTS>
#! <COMMENT
#! IDENTIFIER="7"
#! COMMENT_VALUE="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'helvetica neue'; font-size:13pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PythonCaller reads all</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">the key-value pairs and</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">creates attributes for each.</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If a list element (index) is missing,</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">the corresponding value will</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">also be skipped.</p></body></html>"
#! POSITION="-156.031 198.002"
#! TOP_LEFT="-156.031 198.002"
#! BOTTOM_RIGHT="-157.031 199.002"
#! BOUNDING_RECT="-156.031 198.002 -1 -1"
#! ORDER="5e+14"
#! FOLLOW_ANCHOR="true"
#! INFO_NODE="false"
#! COLOUR="1,1,0.784314,0.192157"
#! SIZE_POLICY="8"
#! COMMENT_TYPE="REGULAR"
#! ANCHORED_NODE="2"
#! />
#! <COMMENT
#! IDENTIFIER="8"
#! COMMENT_VALUE="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'helvetica neue'; font-size:13pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clean up</p></body></html>"
#! POSITION="1076.1 -42.0005"
#! TOP_LEFT="1076.1 -42.0005"
#! BOTTOM_RIGHT="1075.1 -41.0005"
#! BOUNDING_RECT="1076.1 -42.0005 -1 -1"
#! ORDER="5e+14"
#! FOLLOW_ANCHOR="true"
#! INFO_NODE="false"
#! COLOUR="1,1,0.784314,0.192157"
#! SIZE_POLICY="8"
#! COMMENT_TYPE="REGULAR"
#! ANCHORED_NODE="3"
#! />
#! <COMMENT
#! IDENTIFIER="20"
#! COMMENT_VALUE="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'helvetica neue'; font-size:13pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Test for errors</p></body></html>"
#! POSITION="542.912 -42.0004"
#! TOP_LEFT="542.912 -42.0004"
#! BOTTOM_RIGHT="541.912 -41.0004"
#! BOUNDING_RECT="542.912 -42.0004 -1 -1"
#! ORDER="5e+14"
#! FOLLOW_ANCHOR="true"
#! INFO_NODE="false"
#! COLOUR="1,1,0.784314,0.192157"
#! SIZE_POLICY="8"
#! COMMENT_TYPE="REGULAR"
#! ANCHORED_NODE="12"
#! />
#! </COMMENTS>
#! <CONSTANTS>
#! </CONSTANTS>
#! <BOOKMARKS>
#! </BOOKMARKS>
#! <TRANSFORMERS>
#! <TRANSFORMER
#! IDENTIFIER="2"
#! TYPE="PythonCaller"
#! VERSION="4"
#! POSITION="-39.0296 -198.001"
#! BOUNDING_RECT="-39.0296 -198.001 -1 -1"
#! ORDER="5e+14"
#! PARMS_EDITED="true"
#! ENABLED="true"
#! LAST_PARM_EDIT="17291"
#! >
#! <OUTPUT_FEAT NAME="OUTPUT"/>
#! <FEAT_COLLAPSED COLLAPSED="0"/>
#! <XFORM_ATTR ATTR_NAME="__key_attr" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_ATTR ATTR_NAME="__val_attr" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_ATTR ATTR_NAME="__attr_conflict_res" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_ATTR ATTR_NAME="_error" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_PARM PARM_NAME="NEW_ATTRIBUTES" PARM_VALUE="_error"/>
#! <XFORM_PARM PARM_NAME="PYTHONSOURCE" PARM_VALUE="import<space>fme<lf>import<space>fmeobjects<lf>import<space>re<lf><lf>class<space>ListKeyValuePairExtractor<openparen>object<closeparen>:<lf><space><space><space><space>def<space>__init__<openparen>self<closeparen>:<lf><space><space><space><space><space><space><space><space>self.log<space>=<space>fmeobjects.FMELogFile<openparen><closeparen><lf><space><space><space><space><space><space><space><space>self.name<space>=<space>self.__class__.__name__<lf><space><space><space><space><space><space><space><space>self.regex1<space>=<space>re.compile<openparen><apos><opencurly><openparen><backslash>d+<closeparen><closecurly><apos><closeparen><space><space>#<space>only<space>finds<space>the<space>number<space><openparen>get_list_attribute_names<closeparen><lf><space><space><space><space><space><space><space><space>self.regex2<space>=<space>re.compile<openparen><apos><openparen><opencurly><backslash>d+<closecurly><closeparen><apos><closeparen><space><space>#<space>finds<space>number<space>including<space>braces<space><openparen>get_pattern<closeparen><lf><space><space><space><space><lf><space><space><space><space>def<space>input<openparen>self<comma><space>feature<closeparen>:<lf><space><space><space><space><space><space><space><space>#<space>get<space>user<space>input<lf><space><space><space><space><space><space><space><space>key_attr<space>=<space>feature.getAttribute<openparen><apos>__key_attr<apos><closeparen><lf><space><space><space><space><space><space><space><space>val_attr<space>=<space>feature.getAttribute<openparen><apos>__val_attr<apos><closeparen><lf><space><space><space><space><space><space><space><space>overwrite<space>=<space>feature.getAttribute<openparen><apos>__attr_conflict_res<apos><closeparen><lf><space><space><space><space><space><space><space><space><lf><space><space><space><space><space><space><space><space>#<space>check<space>user<space>input<space>and<space>get<space>pattern<space><openparen>prefix<comma><space>suffix<closeparen><lf><space><space><space><space><space><space><space><space>try:<lf><space><space><space><space><space><space><space><space><space><space><space><space>overwrite<space>=<space>bool<openparen>int<openparen>overwrite<closeparen><closeparen><space><space>#<space>cast<space>to<space>boolean<lf><space><space><space><space><space><space><space><space>except<space><openparen>TypeError<comma><space>ValueError<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space>overwrite<space>=<space>False<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>do<space>not<space>overwrite<space>if<space>the<space>cast<space>failed<lf><space><space><space><space><space><space><space><space>key_pattern<space>=<space>self.get_pattern<openparen>key_attr<closeparen><lf><space><space><space><space><space><space><space><space>val_pattern<space>=<space>self.get_pattern<openparen>val_attr<closeparen><lf><space><space><space><space><space><space><space><space>if<space>not<space><openparen>key_pattern<space>and<space>val_pattern<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space>#<space>this<space>should<space>not<space>happen<comma><space>because<space>the<space>UI<space>should<space>address<space>this<space>problem<lf><space><space><space><space><space><space><space><space><space><space><space><space>raise<space>fmeobjects.FMEException<openparen><apos><opencurly><closecurly>:<space>Please<space>supply<space>valid<space>list<space>attributes<space>for<space>the<space>keys<space>and<space>values!<apos>.format<openparen>self.name<closeparen><comma><space>fmeobjects.FME_ERROR<closeparen><lf><space><space><space><space><space><space><space><space><lf><space><space><space><space><space><space><space><space>#<space>create<space>an<space>attribute<space>for<space>each<space>key-value<space>pair<lf><space><space><space><space><space><space><space><space>keys<space>=<space>self.get_list_attribute_names<openparen>feature<comma><space>key_pattern<closeparen><lf><space><space><space><space><space><space><space><space>num_keys<space>=<space>len<openparen>keys<closeparen><lf><space><space><space><space><space><space><space><space>for<space><openparen>key_index<comma><space>key_name<closeparen><space>in<space>keys:<lf><space><space><space><space><space><space><space><space><space><space><space><space><openparen>is_null<comma><space>is_missing<comma><space>attr_type<closeparen><space>=<space>feature.getAttributeNullMissingAndType<openparen>key_name<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>is_null<space>or<space>is_missing:<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>check<space>if<space>the<space>attribute<space>name<space>has<space>a<space>value<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Key<space><apos><opencurly><closecurly><apos><space>does<space>not<space>have<space>a<space>value<quote>.format<openparen>key_name<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_WARN<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space>key_attr<space>=<space>feature.getAttribute<openparen>key_name<closeparen><space><space><space>#<space>get<space>the<space>attribute<space>name<space><openparen>key<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>key_attr<space>==<space><apos><apos>:<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>if<space>the<space>attribute<space>name<space>is<space>an<space>empty<space>string<comma><space>we<space>will<space>skip<space>it<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Key<space><apos><opencurly><closecurly><apos><space>contains<space>an<space>empty<space>string<quote>.format<openparen>key_name<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_WARN<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space>val_attr<space>=<space><apos><opencurly><closecurly><opencurly><opencurly><opencurly><closecurly><closecurly><closecurly><opencurly><closecurly><apos>.format<openparen>val_pattern<openbracket>0<closebracket><comma><space>key_index<comma><space>val_pattern<openbracket>1<closebracket><closeparen><space><space>#<space>matching<space>value<space>attribute<space>name<lf><space><space><space><space><space><space><space><space><space><space><space><space><openparen>val_null<comma><space>val_missing<comma><space>val_type<closeparen><space>=<space>feature.getAttributeNullMissingAndType<openparen>val_attr<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>val_missing:<space><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>if<space>the<space>corresponding<space>value<space>does<space>not<space>exist<comma><space>show<space>a<space>warning<space>and<space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Matching<space>value<space><apos><opencurly><closecurly><apos><space>for<space>key<space><apos><opencurly><closecurly><apos><space><openparen><apos><opencurly><closecurly><apos><closeparen><space>does<space>not<space>exist<quote>.format<openparen>val_attr<comma><space>key_name<comma><space>key_attr<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_WARN<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>not<space>overwrite:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><openparen>key_null<comma><space>key_missing<comma><space>key_type<closeparen><space>=<space>feature.getAttributeNullMissingAndType<openparen>key_attr<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>if<space>not<space><openparen>key_null<space>or<space>key_missing<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>do<space>not<space>write<space>if<space>overwrite<space>=<space>False<space>and<space>key<space>attribute<space>has<space>a<space>value<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>val_null:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttributeNullWithType<openparen>key_attr<comma><space>val_type<closeparen><space><space><space><space>#<space>set<space>null<space>if<space>value<space>is<space>actually<space>null<lf><space><space><space><space><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>value<space>=<space>feature.getAttribute<openparen>val_attr<closeparen><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>get<space>the<space>attribute<space>value<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>error<space>=<space>self.write_attribute<openparen>feature<comma><space>key_attr<comma><space>value<closeparen><space><space>#<space>safely<space>write<space>attribute<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>error:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Could<space>not<space>write<space>value<space><apos><opencurly><closecurly><apos><space>for<space>key<space><apos><opencurly><closecurly><apos>:<space><opencurly><closecurly><quote>.format<openparen>val_attr<comma><space>key_name<comma><space>error<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_ERROR<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space>if<space>num_keys<space>==<space>0:<lf><space><space><space><space><space><space><space><space><space><space><space><space>#<space>if<space>there<space>are<space>no<space>keys<space>in<space>the<space>list<space><openparen>or<space>none<space>left<space>after<space>all<space>the<space>warnings<solidus>errors<closeparen><comma><space>reject<space>the<space>feature<lf><space><space><space><space><space><space><space><space><space><space><space><space>prefix<comma><space>suffix<space>=<space>key_pattern<lf><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>No<space><openparen>valid<closeparen><space>keys<space>were<space>found<space>in<space>list<space><apos><opencurly><closecurly><opencurly><closecurly><opencurly><closecurly><apos><space>or<space>there<space>was<space>a<space>problem<space>writing<space>their<space>values.<quote>.format<openparen>prefix<comma><space><apos><opencurly><closecurly><apos><comma><space>suffix<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>self.log_error<openparen>feature<comma><space>msg<closeparen><lf><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space>feature.removeAttribute<openparen><apos>_error<apos><closeparen><space><space>#<space>make<space>sure<space>that<space>an<space>existing<space>_error<space>attribute<space>does<space>not<space>interfere<space>here<lf><space><space><space><space><space><space><space><space>self.pyoutput<openparen>feature<closeparen><lf><lf><space><space><space><space>def<space>log_error<openparen>self<comma><space>feature<comma><space>message<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Logs<space>an<space>error<space>and<space>writes<space>it<space>to<space>the<space>_error<space>attribute.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>message<closeparen><comma><space>fmeobjects.FME_ERROR<closeparen><lf><space><space><space><space><space><space><space><space>feature.setAttribute<openparen><apos>_error<apos><comma><space><quote><opencurly><closecurly><space><opencurly><closecurly><quote>.format<openparen>message<comma><space><quote>Please<space>check<space>the<space>logfile.<quote><closeparen><closeparen><lf><lf><space><space><space><space>def<space>write_attribute<openparen>self<comma><space>feature<comma><space>name<comma><space>value<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Tries<space>to<space>write<space>an<space>attribute<space><apos>safely<apos>.<lf><space><space><space><space><space><space><space><space>If<space>the<space>attribute<space>name<space>has<space>a<space>unicode<space>type<space><openparen>Python<space><lt><space>3<closeparen><comma><space>try<space>to<space>encode<space>it.<lf><space><space><space><space><space><space><space><space>If<space>the<space>attribute<space>name<space>is<space>not<space>a<space>string<comma><space>it<space>will<space>be<space>converted<space>into<space>one.<lf><space><space><space><space><space><space><space><space>Otherwise<comma><space>skip<space>the<space>attribute<space>and<space>return<space>an<space>error<space>code.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>result<space>=<space>None<lf><space><space><space><space><space><space><space><space>try:<lf><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttribute<openparen>name<comma><space>value<closeparen><space><space><space>#<space><openparen>over<closeparen>write<space>the<space>exploded<space>attribute<lf><space><space><space><space><space><space><space><space>except<space>TypeError:<lf><space><space><space><space><space><space><space><space><space><space><space><space>try:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>if<space>hasattr<openparen>name<comma><space><apos>encode<apos><closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttribute<openparen>name.encode<openparen><apos>utf8<apos><closeparen><comma><space>value<closeparen><space><space>#<space>for<space>Python<space><lt><space>3<comma><space>there<space>might<space>be<space>a<space>unicode<space>issue<comma><space>so<space>let<apos>s<space>try<space>to<space>handle<space>that<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttribute<openparen>str<openparen>name<closeparen><comma><space>value<closeparen><space><space><space><space><space><space><space><space><space><space><space><space>#<space>cast<space>to<space>str<lf><space><space><space><space><space><space><space><space><space><space><space><space>except<space>Exception<space>as<space>e:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space>e<lf><space><space><space><space><space><space><space><space>except<space>Exception<space>as<space>e:<lf><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space>e<lf><space><space><space><space><space><space><space><space>return<space>result<lf><space><space><space><space><space><space><space><space><lf><space><space><space><space>def<space>get_list_attribute_names<openparen>self<comma><space>feature<comma><space>pattern<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Retrieves<space>a<space>list<space>of<space>attribute<space>names<space>based<space>on<space>a<space>pattern<space><openparen>prefix<comma><space>suffix<closeparen>.<lf><space><space><space><space><space><space><space><space>This<space>is<space>necessary<space>because<space>a<space>list<space>could<space>have<space>missing<space>indices<comma><lf><space><space><space><space><space><space><space><space>so<space>simply<space>calling<space>feature.getAttribute<openparen><apos>list<opencurly><closecurly><apos><closeparen><space>might<space>not<space>work<space>properly<lf><space><space><space><space><space><space><space><space>when<space>we<space>want<space>to<space>match<space>the<space>values<space>to<space>another<space>list<space>of<space><openparen>un<closeparen>equal<space>length<comma><space>as<lf><space><space><space><space><space><space><space><space>that<space>gives<space>us<space>a<space>list<space>where<space>the<space>missing<space>values<space>have<space>been<space>removed.<lf><space><space><space><space><space><space><space><space>Returns<space>a<space>list<space>of<space>tuples<space><openbracket><openparen>index<comma><space>attribute<space>name<closeparen><comma><space>...<closebracket>.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>prefix<comma><space>suffix<space>=<space>pattern<lf><space><space><space><space><space><space><space><space>attributes<space>=<space>feature.getAllAttributeNames<openparen><closeparen><space><space><space><space><space>#<space>get<space>all<space>attribute<space>names<lf><space><space><space><space><space><space><space><space>result_list<space>=<space><openbracket><closebracket><lf><space><space><space><space><space><space><space><space>for<space>attr<space>in<space>attributes:<lf><space><space><space><space><space><space><space><space><space><space><space><space>#<space>filter<space>out<space>the<space>attributes<space>we<space>need<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>attr.startswith<openparen>prefix<closeparen><space>and<space>attr.endswith<openparen>suffix<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>index<space>=<space>self.regex1.findall<openparen>attr<closeparen><openbracket>-1<closebracket><space><space><space>#<space>gets<space>the<space>last<space>number<space><openparen>=<space>list<space>index<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>result_list.append<openparen><openparen>index<comma><space>attr<closeparen><closeparen><lf><space><space><space><space><space><space><space><space>return<space>sorted<openparen>result_list<closeparen><lf><lf><space><space><space><space>def<space>get_pattern<openparen>self<comma><space>list_attr<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Checks<space>if<space>the<space>input<space>is<space>a<space>list<space>attribute.<space>If<space>not<comma><space>returns<space>None.<lf><space><space><space><space><space><space><space><space>If<space>it<space>is<comma><space>it<space>will<space>return<space>a<space><quote>search<space>pattern<quote><space><openparen>tuple<space>of<space>pre-<space>and<space>suffix<closeparen><lf><space><space><space><space><space><space><space><space>that<space>can<space>be<space>used<space>to<space>fetch<space>all<space>list<space>attributes<space>that<space>match<space>the<space>pattern.<lf><space><space><space><space><space><space><space><space>Returns<space>a<space>tuple<space><openparen>attribute<space>prefix<comma><space>attribute<space>suffix<closeparen>.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>if<space>not<space>list_attr:<lf><space><space><space><space><space><space><space><space><space><space><space><space>return<space>None<space><space>#<space>if<space>attribute<space>is<space><apos><apos><space>or<space>None<comma><space>return<space>nothing<lf><space><space><space><space><space><space><space><space>groups<space>=<space>self.regex2.findall<openparen>list_attr<closeparen><lf><space><space><space><space><space><space><space><space>if<space>len<openparen>groups<closeparen><space>==<space>0:<lf><space><space><space><space><space><space><space><space><space><space><space><space>return<space>None<space><space>#<space>if<space>there<space>are<space>no<space>groups<comma><space>it<apos>s<space>not<space>a<space>list<space>attribute<lf><space><space><space><space><space><space><space><space>split_list<space>=<space>self.regex2.split<openparen>list_attr<closeparen><lf><space><space><space><space><space><space><space><space>max_index<space>=<space>len<openparen>split_list<closeparen><space>-<space>1<lf><space><space><space><space><space><space><space><space>#<space>find<space>the<space>last<space>occurence<space>of<space><opencurly>n<closecurly><space>-<gt><space>search<space>backwards<lf><space><space><space><space><space><space><space><space>split_pos<space>=<space>-1<lf><space><space><space><space><space><space><space><space>for<space>i<space>in<space>range<openparen>max_index<comma><space>-1<comma><space>-1<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>split_list<openbracket>i<closebracket><space>==<space>groups<openbracket>-1<closebracket>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>split_pos<space>=<space>i<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>break<lf><space><space><space><space><space><space><space><space>if<space>split_pos<space><lt><space>max_index:<lf><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space><openparen>str.join<openparen><apos><apos><comma><space>split_list<openbracket>:split_pos<closebracket><closeparen><comma><space>split_list<openbracket>split_pos<space>+<space>1<closebracket><closeparen><lf><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space><openparen>str.join<openparen><apos><apos><comma><space>split_list<openbracket>:max_index<closebracket><closeparen><comma><space><apos><apos><closeparen><lf><space><space><space><space><space><space><space><space>return<space>result<lf><space><space><space><space><space><space><space><space><lf><space><space><space><space>def<space>close<openparen>self<closeparen>:<lf><space><space><space><space><space><space><space><space>del<space>self"/>
#! <XFORM_PARM PARM_NAME="XFORMER_NAME" PARM_VALUE="PythonCaller"/>
#! <XFORM_PARM PARM_NAME="PYTHONSYMBOL" PARM_VALUE="ListKeyValuePairExtractor"/>
#! <XFORM_PARM PARM_NAME="TRANSFORMER_GROUP" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="ADVANCED_GROUP" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="HIDE_ATTRIBUTES" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="LIST_ATTRS" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="PARAMETERS_GROUP" PARM_VALUE=""/>
#! </TRANSFORMER>
#! <TRANSFORMER
#! IDENTIFIER="3"
#! TYPE="AttributeRemover"
#! VERSION="1"
#! POSITION="1000.54 -198.001"
#! BOUNDING_RECT="1000.54 -198.001 -1 -1"
#! ORDER="5e+14"
#! PARMS_EDITED="true"
#! ENABLED="true"
#! LAST_PARM_EDIT="17291"
#! >
#! <OUTPUT_FEAT NAME="OUTPUT"/>
#! <FEAT_COLLAPSED COLLAPSED="0"/>
#! <XFORM_PARM PARM_NAME="REMOVE_ATTRS" PARM_VALUE="__attr_conflict_res,__key_attr,_error,__val_attr"/>
#! <XFORM_PARM PARM_NAME="XFORMER_NAME" PARM_VALUE="AttributeRemover"/>
#! <XFORM_PARM PARM_NAME="TRANSFORMER_GROUP" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="LIST_ATTRS" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="PARAMETERS_GROUP" PARM_VALUE=""/>
#! </TRANSFORMER>
#! <TRANSFORMER
#! IDENTIFIER="12"
#! TYPE="Tester"
#! VERSION="2"
#! POSITION="481.505 -198.001"
#! BOUNDING_RECT="481.505 -198.001 -1 -1"
#! ORDER="5e+14"
#! PARMS_EDITED="true"
#! ENABLED="true"
#! LAST_PARM_EDIT="17291"
#! >
#! <OUTPUT_FEAT NAME="PASSED"/>
#! <FEAT_COLLAPSED COLLAPSED="0"/>
#! <XFORM_ATTR ATTR_NAME="__key_attr" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_ATTR ATTR_NAME="__val_attr" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_ATTR ATTR_NAME="__attr_conflict_res" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_ATTR ATTR_NAME="_error" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <OUTPUT_FEAT NAME="FAILED"/>
#! <FEAT_COLLAPSED COLLAPSED="1"/>
#! <XFORM_ATTR ATTR_NAME="__key_attr" IS_USER_CREATED="false" FEAT_INDEX="1" />
#! <XFORM_ATTR ATTR_NAME="__val_attr" IS_USER_CREATED="false" FEAT_INDEX="1" />
#! <XFORM_ATTR ATTR_NAME="__attr_conflict_res" IS_USER_CREATED="false" FEAT_INDEX="1" />
#! <XFORM_ATTR ATTR_NAME="_error" IS_USER_CREATED="false" FEAT_INDEX="1" />
#! <XFORM_PARM PARM_NAME="TEST_LIST" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="XFORMER_NAME" PARM_VALUE="Tester"/>
#! <XFORM_PARM PARM_NAME="BOOL_OP" PARM_VALUE="OR"/>
#! <XFORM_PARM PARM_NAME="COMPOSITE_TEST" PARM_VALUE="<Unused>"/>
#! <XFORM_PARM PARM_NAME="TEST_MODE" PARM_VALUE="Automatic"/>
#! <XFORM_PARM PARM_NAME="TEST_DESCRIPTION" PARM_VALUE=""""/>
#! <XFORM_PARM PARM_NAME="TEST_CLAUSE" PARM_VALUE="TEST <at>Value<openparen>_error<closeparen> NOT_ATTRIBUTE_HAS_VALUE """/>
#! </TRANSFORMER>
#! <TRANSFORMER
#! IDENTIFIER="16"
#! TYPE="AttributeRemover"
#! VERSION="1"
#! POSITION="1000.54 -359.001"
#! BOUNDING_RECT="1000.54 -359.001 -1 -1"
#! ORDER="5e+14"
#! PARMS_EDITED="true"
#! ENABLED="true"
#! LAST_PARM_EDIT="17291"
#! >
#! <OUTPUT_FEAT NAME="OUTPUT"/>
#! <FEAT_COLLAPSED COLLAPSED="0"/>
#! <XFORM_ATTR ATTR_NAME="_error" IS_USER_CREATED="false" FEAT_INDEX="0" />
#! <XFORM_PARM PARM_NAME="REMOVE_ATTRS" PARM_VALUE="__key_attr,__val_attr,__attr_conflict_res"/>
#! <XFORM_PARM PARM_NAME="XFORMER_NAME" PARM_VALUE="AttributeRemover_2"/>
#! <XFORM_PARM PARM_NAME="TRANSFORMER_GROUP" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="LIST_ATTRS" PARM_VALUE=""/>
#! <XFORM_PARM PARM_NAME="PARAMETERS_GROUP" PARM_VALUE=""/>
#! </TRANSFORMER>
#! </TRANSFORMERS>
#! <SUBDOCUMENT_IOS>
#! <SUBDOCUMENT_IO
#! IDENTIFIER="9"
#! NAME="Output"
#! POSITION="1518.01 -198.001"
#! BOUNDING_RECT="1518.01 -198.001 -1 -1"
#! COLLAPSED="true"
#! IS_SOURCE="false"
#! ATTR_MODE="0"
#! >
#! </SUBDOCUMENT_IO>
#! <SUBDOCUMENT_IO
#! IDENTIFIER="11"
#! NAME="Input"
#! POSITION="-576.525 -198.001"
#! BOUNDING_RECT="-576.525 -198.001 -1 -1"
#! COLLAPSED="true"
#! PUBLISHED="true"
#! IS_SOURCE="true"
#! ATTR_MODE="0"
#! >
#! <XFORM_ATTR ATTR_NAME="__key_attr" ATTR_VALUE="$(__KEY_ATTR)" />
#! <XFORM_ATTR ATTR_NAME="__val_attr" ATTR_VALUE="$(__VAL_ATTR)" />
#! <XFORM_ATTR ATTR_NAME="__attr_conflict_res" ATTR_VALUE="$(__ATTR_CONFLICT_RES)" />
#! </SUBDOCUMENT_IO>
#! <SUBDOCUMENT_IO
#! IDENTIFIER="18"
#! NAME="<Rejected>"
#! POSITION="1518.01 -359.001"
#! BOUNDING_RECT="1518.01 -359.001 -1 -1"
#! COLLAPSED="false"
#! IS_SOURCE="false"
#! ATTR_MODE="0"
#! >
#! </SUBDOCUMENT_IO>
#! </SUBDOCUMENT_IOS>
#! <FEAT_LINKS>
#! <FEAT_LINK
#! IDENTIFIER="13"
#! SOURCE_NODE="11"
#! TARGET_NODE="2"
#! SOURCE_PORT_DESC="0"
#! TARGET_PORT_DESC="fi 0 "
#! ENABLED="true"
#! EXECUTION_IDX="0"
#! HIDDEN="false"
#! EXTRA_POINTS=""
#! />
#! <FEAT_LINK
#! IDENTIFIER="14"
#! SOURCE_NODE="2"
#! TARGET_NODE="12"
#! SOURCE_PORT_DESC="fo 0 OUTPUT"
#! TARGET_PORT_DESC="fi 0 "
#! ENABLED="true"
#! EXECUTION_IDX="0"
#! HIDDEN="false"
#! EXTRA_POINTS=""
#! />
#! <FEAT_LINK
#! IDENTIFIER="10"
#! SOURCE_NODE="3"
#! TARGET_NODE="9"
#! SOURCE_PORT_DESC="fo 0 OUTPUT"
#! TARGET_PORT_DESC="0"
#! ENABLED="true"
#! EXECUTION_IDX="0"
#! HIDDEN="false"
#! EXTRA_POINTS=""
#! />
#! <FEAT_LINK
#! IDENTIFIER="15"
#! SOURCE_NODE="12"
#! TARGET_NODE="3"
#! SOURCE_PORT_DESC="fo 0 PASSED"
#! TARGET_PORT_DESC="fi 0 "
#! ENABLED="true"
#! EXECUTION_IDX="0"
#! HIDDEN="false"
#! EXTRA_POINTS=""
#! />
#! <FEAT_LINK
#! IDENTIFIER="19"
#! SOURCE_NODE="16"
#! TARGET_NODE="18"
#! SOURCE_PORT_DESC="fo 0 OUTPUT"
#! TARGET_PORT_DESC="0"
#! ENABLED="true"
#! EXECUTION_IDX="0"
#! HIDDEN="false"
#! EXTRA_POINTS=""
#! />
#! <FEAT_LINK
#! IDENTIFIER="17"
#! SOURCE_NODE="12"
#! TARGET_NODE="16"
#! SOURCE_PORT_DESC="fo 1 FAILED"
#! TARGET_PORT_DESC="fi 0 "
#! ENABLED="true"
#! EXECUTION_IDX="0"
#! HIDDEN="false"
#! EXTRA_POINTS=""
#! />
#! </FEAT_LINKS>
#! <BREAKPOINTS>
#! </BREAKPOINTS>
#! <ATTR_LINKS>
#! </ATTR_LINKS>
#! <SUBDOCUMENTS>
#! </SUBDOCUMENTS>
#! <LOOKUP_TABLES>
#! </LOOKUP_TABLES>
#! </TRANSFORMER>
FME_PYTHON_VERSION 2or3
DEFAULT_MACRO $(ListKeyValuePairExtractor_WORKSPACE_NAME)___KEY_ATTR
DEFAULT_MACRO $(ListKeyValuePairExtractor_WORKSPACE_NAME)___VAL_ATTR
DEFAULT_MACRO $(ListKeyValuePairExtractor_WORKSPACE_NAME)___ATTR_CONFLICT_RES 1
#! START_HEADER
#! END_HEADER
LOG_FILTER_MASK -1
DEFAULT_MACRO WB_CURRENT_CONTEXT
DEFAULT_MACRO ListKeyValuePairExtractor_WORKSPACE_NAME ""
INCLUDE [puts {MACRO WB_OLD_CONTEXT_$(ListKeyValuePairExtractor_WORKSPACE_NAME) $(WB_CURRENT_CONTEXT)}; puts {MACRO WB_CURRENT_CONTEXT $(ListKeyValuePairExtractor_WORKSPACE_NAME)}]
FACTORY_DEF * TeeFactory FACTORY_NAME "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Input1505392804 Input Splitter" INPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Input" OUTPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Input" "@EvaluateExpression(ATTR_CREATE_EXPR_PROPAGATE_MISSING_FDIV,__key_attr,$($(ListKeyValuePairExtractor_WORKSPACE_NAME)___KEY_ATTR$encode),__val_attr,$($(ListKeyValuePairExtractor_WORKSPACE_NAME)___VAL_ATTR$encode),__attr_conflict_res,$($(ListKeyValuePairExtractor_WORKSPACE_NAME)___ATTR_CONFLICT_RES), FEATURE_TYPE)"
# -------------------------------------------------------------------------
FME_PYTHON_PATH "$(FME_MF_DIR)"
FACTORY_DEF * PythonFactory FACTORY_NAME $(ListKeyValuePairExtractor_WORKSPACE_NAME)_PythonCaller INPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Input" SYMBOL_NAME ListKeyValuePairExtractor PYTHON_NAMESPACE FMEOBJECTS SOURCE_CODE import<space>fme<lf>import<space>fmeobjects<lf>import<space>re<lf><lf>class<space>ListKeyValuePairExtractor<openparen>object<closeparen>:<lf><space><space><space><space>def<space>__init__<openparen>self<closeparen>:<lf><space><space><space><space><space><space><space><space>self.log<space>=<space>fmeobjects.FMELogFile<openparen><closeparen><lf><space><space><space><space><space><space><space><space>self.name<space>=<space>self.__class__.__name__<lf><space><space><space><space><space><space><space><space>self.regex1<space>=<space>re.compile<openparen><apos><opencurly><openparen><backslash>d+<closeparen><closecurly><apos><closeparen><space><space>#<space>only<space>finds<space>the<space>number<space><openparen>get_list_attribute_names<closeparen><lf><space><space><space><space><space><space><space><space>self.regex2<space>=<space>re.compile<openparen><apos><openparen><opencurly><backslash>d+<closecurly><closeparen><apos><closeparen><space><space>#<space>finds<space>number<space>including<space>braces<space><openparen>get_pattern<closeparen><lf><space><space><space><space><lf><space><space><space><space>def<space>input<openparen>self<comma><space>feature<closeparen>:<lf><space><space><space><space><space><space><space><space>#<space>get<space>user<space>input<lf><space><space><space><space><space><space><space><space>key_attr<space>=<space>feature.getAttribute<openparen><apos>__key_attr<apos><closeparen><lf><space><space><space><space><space><space><space><space>val_attr<space>=<space>feature.getAttribute<openparen><apos>__val_attr<apos><closeparen><lf><space><space><space><space><space><space><space><space>overwrite<space>=<space>feature.getAttribute<openparen><apos>__attr_conflict_res<apos><closeparen><lf><space><space><space><space><space><space><space><space><lf><space><space><space><space><space><space><space><space>#<space>check<space>user<space>input<space>and<space>get<space>pattern<space><openparen>prefix<comma><space>suffix<closeparen><lf><space><space><space><space><space><space><space><space>try:<lf><space><space><space><space><space><space><space><space><space><space><space><space>overwrite<space>=<space>bool<openparen>int<openparen>overwrite<closeparen><closeparen><space><space>#<space>cast<space>to<space>boolean<lf><space><space><space><space><space><space><space><space>except<space><openparen>TypeError<comma><space>ValueError<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space>overwrite<space>=<space>False<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>do<space>not<space>overwrite<space>if<space>the<space>cast<space>failed<lf><space><space><space><space><space><space><space><space>key_pattern<space>=<space>self.get_pattern<openparen>key_attr<closeparen><lf><space><space><space><space><space><space><space><space>val_pattern<space>=<space>self.get_pattern<openparen>val_attr<closeparen><lf><space><space><space><space><space><space><space><space>if<space>not<space><openparen>key_pattern<space>and<space>val_pattern<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space>#<space>this<space>should<space>not<space>happen<comma><space>because<space>the<space>UI<space>should<space>address<space>this<space>problem<lf><space><space><space><space><space><space><space><space><space><space><space><space>raise<space>fmeobjects.FMEException<openparen><apos><opencurly><closecurly>:<space>Please<space>supply<space>valid<space>list<space>attributes<space>for<space>the<space>keys<space>and<space>values!<apos>.format<openparen>self.name<closeparen><comma><space>fmeobjects.FME_ERROR<closeparen><lf><space><space><space><space><space><space><space><space><lf><space><space><space><space><space><space><space><space>#<space>create<space>an<space>attribute<space>for<space>each<space>key-value<space>pair<lf><space><space><space><space><space><space><space><space>keys<space>=<space>self.get_list_attribute_names<openparen>feature<comma><space>key_pattern<closeparen><lf><space><space><space><space><space><space><space><space>num_keys<space>=<space>len<openparen>keys<closeparen><lf><space><space><space><space><space><space><space><space>for<space><openparen>key_index<comma><space>key_name<closeparen><space>in<space>keys:<lf><space><space><space><space><space><space><space><space><space><space><space><space><openparen>is_null<comma><space>is_missing<comma><space>attr_type<closeparen><space>=<space>feature.getAttributeNullMissingAndType<openparen>key_name<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>is_null<space>or<space>is_missing:<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>check<space>if<space>the<space>attribute<space>name<space>has<space>a<space>value<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Key<space><apos><opencurly><closecurly><apos><space>does<space>not<space>have<space>a<space>value<quote>.format<openparen>key_name<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_WARN<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space>key_attr<space>=<space>feature.getAttribute<openparen>key_name<closeparen><space><space><space>#<space>get<space>the<space>attribute<space>name<space><openparen>key<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>key_attr<space>==<space><apos><apos>:<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>if<space>the<space>attribute<space>name<space>is<space>an<space>empty<space>string<comma><space>we<space>will<space>skip<space>it<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Key<space><apos><opencurly><closecurly><apos><space>contains<space>an<space>empty<space>string<quote>.format<openparen>key_name<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_WARN<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space>val_attr<space>=<space><apos><opencurly><closecurly><opencurly><opencurly><opencurly><closecurly><closecurly><closecurly><opencurly><closecurly><apos>.format<openparen>val_pattern<openbracket>0<closebracket><comma><space>key_index<comma><space>val_pattern<openbracket>1<closebracket><closeparen><space><space>#<space>matching<space>value<space>attribute<space>name<lf><space><space><space><space><space><space><space><space><space><space><space><space><openparen>val_null<comma><space>val_missing<comma><space>val_type<closeparen><space>=<space>feature.getAttributeNullMissingAndType<openparen>val_attr<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>val_missing:<space><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>if<space>the<space>corresponding<space>value<space>does<space>not<space>exist<comma><space>show<space>a<space>warning<space>and<space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Matching<space>value<space><apos><opencurly><closecurly><apos><space>for<space>key<space><apos><opencurly><closecurly><apos><space><openparen><apos><opencurly><closecurly><apos><closeparen><space>does<space>not<space>exist<quote>.format<openparen>val_attr<comma><space>key_name<comma><space>key_attr<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_WARN<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>not<space>overwrite:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><openparen>key_null<comma><space>key_missing<comma><space>key_type<closeparen><space>=<space>feature.getAttributeNullMissingAndType<openparen>key_attr<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>if<space>not<space><openparen>key_null<space>or<space>key_missing<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>continue<space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>do<space>not<space>write<space>if<space>overwrite<space>=<space>False<space>and<space>key<space>attribute<space>has<space>a<space>value<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>val_null:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttributeNullWithType<openparen>key_attr<comma><space>val_type<closeparen><space><space><space><space>#<space>set<space>null<space>if<space>value<space>is<space>actually<space>null<lf><space><space><space><space><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>value<space>=<space>feature.getAttribute<openparen>val_attr<closeparen><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>#<space>get<space>the<space>attribute<space>value<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>error<space>=<space>self.write_attribute<openparen>feature<comma><space>key_attr<comma><space>value<closeparen><space><space>#<space>safely<space>write<space>attribute<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>error:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>Could<space>not<space>write<space>value<space><apos><opencurly><closecurly><apos><space>for<space>key<space><apos><opencurly><closecurly><apos>:<space><opencurly><closecurly><quote>.format<openparen>val_attr<comma><space>key_name<comma><space>error<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>msg<closeparen><comma><space>fmeobjects.FME_ERROR<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>num_keys<space>-=<space>1<lf><space><space><space><space><space><space><space><space>if<space>num_keys<space>==<space>0:<lf><space><space><space><space><space><space><space><space><space><space><space><space>#<space>if<space>there<space>are<space>no<space>keys<space>in<space>the<space>list<space><openparen>or<space>none<space>left<space>after<space>all<space>the<space>warnings<solidus>errors<closeparen><comma><space>reject<space>the<space>feature<lf><space><space><space><space><space><space><space><space><space><space><space><space>prefix<comma><space>suffix<space>=<space>key_pattern<lf><space><space><space><space><space><space><space><space><space><space><space><space>msg<space>=<space><quote>No<space><openparen>valid<closeparen><space>keys<space>were<space>found<space>in<space>list<space><apos><opencurly><closecurly><opencurly><closecurly><opencurly><closecurly><apos><space>or<space>there<space>was<space>a<space>problem<space>writing<space>their<space>values.<quote>.format<openparen>prefix<comma><space><apos><opencurly><closecurly><apos><comma><space>suffix<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space>self.log_error<openparen>feature<comma><space>msg<closeparen><lf><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space>feature.removeAttribute<openparen><apos>_error<apos><closeparen><space><space>#<space>make<space>sure<space>that<space>an<space>existing<space>_error<space>attribute<space>does<space>not<space>interfere<space>here<lf><space><space><space><space><space><space><space><space>self.pyoutput<openparen>feature<closeparen><lf><lf><space><space><space><space>def<space>log_error<openparen>self<comma><space>feature<comma><space>message<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Logs<space>an<space>error<space>and<space>writes<space>it<space>to<space>the<space>_error<space>attribute.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>self.log.logMessageString<openparen><quote><opencurly><closecurly>:<space><opencurly><closecurly><quote>.format<openparen>self.name<comma><space>message<closeparen><comma><space>fmeobjects.FME_ERROR<closeparen><lf><space><space><space><space><space><space><space><space>feature.setAttribute<openparen><apos>_error<apos><comma><space><quote><opencurly><closecurly><space><opencurly><closecurly><quote>.format<openparen>message<comma><space><quote>Please<space>check<space>the<space>logfile.<quote><closeparen><closeparen><lf><lf><space><space><space><space>def<space>write_attribute<openparen>self<comma><space>feature<comma><space>name<comma><space>value<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Tries<space>to<space>write<space>an<space>attribute<space><apos>safely<apos>.<lf><space><space><space><space><space><space><space><space>If<space>the<space>attribute<space>name<space>has<space>a<space>unicode<space>type<space><openparen>Python<space><lt><space>3<closeparen><comma><space>try<space>to<space>encode<space>it.<lf><space><space><space><space><space><space><space><space>If<space>the<space>attribute<space>name<space>is<space>not<space>a<space>string<comma><space>it<space>will<space>be<space>converted<space>into<space>one.<lf><space><space><space><space><space><space><space><space>Otherwise<comma><space>skip<space>the<space>attribute<space>and<space>return<space>an<space>error<space>code.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>result<space>=<space>None<lf><space><space><space><space><space><space><space><space>try:<lf><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttribute<openparen>name<comma><space>value<closeparen><space><space><space>#<space><openparen>over<closeparen>write<space>the<space>exploded<space>attribute<lf><space><space><space><space><space><space><space><space>except<space>TypeError:<lf><space><space><space><space><space><space><space><space><space><space><space><space>try:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>if<space>hasattr<openparen>name<comma><space><apos>encode<apos><closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttribute<openparen>name.encode<openparen><apos>utf8<apos><closeparen><comma><space>value<closeparen><space><space>#<space>for<space>Python<space><lt><space>3<comma><space>there<space>might<space>be<space>a<space>unicode<space>issue<comma><space>so<space>let<apos>s<space>try<space>to<space>handle<space>that<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>feature.setAttribute<openparen>str<openparen>name<closeparen><comma><space>value<closeparen><space><space><space><space><space><space><space><space><space><space><space><space>#<space>cast<space>to<space>str<lf><space><space><space><space><space><space><space><space><space><space><space><space>except<space>Exception<space>as<space>e:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space>e<lf><space><space><space><space><space><space><space><space>except<space>Exception<space>as<space>e:<lf><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space>e<lf><space><space><space><space><space><space><space><space>return<space>result<lf><space><space><space><space><space><space><space><space><lf><space><space><space><space>def<space>get_list_attribute_names<openparen>self<comma><space>feature<comma><space>pattern<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Retrieves<space>a<space>list<space>of<space>attribute<space>names<space>based<space>on<space>a<space>pattern<space><openparen>prefix<comma><space>suffix<closeparen>.<lf><space><space><space><space><space><space><space><space>This<space>is<space>necessary<space>because<space>a<space>list<space>could<space>have<space>missing<space>indices<comma><lf><space><space><space><space><space><space><space><space>so<space>simply<space>calling<space>feature.getAttribute<openparen><apos>list<opencurly><closecurly><apos><closeparen><space>might<space>not<space>work<space>properly<lf><space><space><space><space><space><space><space><space>when<space>we<space>want<space>to<space>match<space>the<space>values<space>to<space>another<space>list<space>of<space><openparen>un<closeparen>equal<space>length<comma><space>as<lf><space><space><space><space><space><space><space><space>that<space>gives<space>us<space>a<space>list<space>where<space>the<space>missing<space>values<space>have<space>been<space>removed.<lf><space><space><space><space><space><space><space><space>Returns<space>a<space>list<space>of<space>tuples<space><openbracket><openparen>index<comma><space>attribute<space>name<closeparen><comma><space>...<closebracket>.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>prefix<comma><space>suffix<space>=<space>pattern<lf><space><space><space><space><space><space><space><space>attributes<space>=<space>feature.getAllAttributeNames<openparen><closeparen><space><space><space><space><space>#<space>get<space>all<space>attribute<space>names<lf><space><space><space><space><space><space><space><space>result_list<space>=<space><openbracket><closebracket><lf><space><space><space><space><space><space><space><space>for<space>attr<space>in<space>attributes:<lf><space><space><space><space><space><space><space><space><space><space><space><space>#<space>filter<space>out<space>the<space>attributes<space>we<space>need<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>attr.startswith<openparen>prefix<closeparen><space>and<space>attr.endswith<openparen>suffix<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>index<space>=<space>self.regex1.findall<openparen>attr<closeparen><openbracket>-1<closebracket><space><space><space>#<space>gets<space>the<space>last<space>number<space><openparen>=<space>list<space>index<closeparen><lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>result_list.append<openparen><openparen>index<comma><space>attr<closeparen><closeparen><lf><space><space><space><space><space><space><space><space>return<space>sorted<openparen>result_list<closeparen><lf><lf><space><space><space><space>def<space>get_pattern<openparen>self<comma><space>list_attr<closeparen>:<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>Checks<space>if<space>the<space>input<space>is<space>a<space>list<space>attribute.<space>If<space>not<comma><space>returns<space>None.<lf><space><space><space><space><space><space><space><space>If<space>it<space>is<comma><space>it<space>will<space>return<space>a<space><quote>search<space>pattern<quote><space><openparen>tuple<space>of<space>pre-<space>and<space>suffix<closeparen><lf><space><space><space><space><space><space><space><space>that<space>can<space>be<space>used<space>to<space>fetch<space>all<space>list<space>attributes<space>that<space>match<space>the<space>pattern.<lf><space><space><space><space><space><space><space><space>Returns<space>a<space>tuple<space><openparen>attribute<space>prefix<comma><space>attribute<space>suffix<closeparen>.<lf><space><space><space><space><space><space><space><space><quote><quote><quote><lf><space><space><space><space><space><space><space><space>if<space>not<space>list_attr:<lf><space><space><space><space><space><space><space><space><space><space><space><space>return<space>None<space><space>#<space>if<space>attribute<space>is<space><apos><apos><space>or<space>None<comma><space>return<space>nothing<lf><space><space><space><space><space><space><space><space>groups<space>=<space>self.regex2.findall<openparen>list_attr<closeparen><lf><space><space><space><space><space><space><space><space>if<space>len<openparen>groups<closeparen><space>==<space>0:<lf><space><space><space><space><space><space><space><space><space><space><space><space>return<space>None<space><space>#<space>if<space>there<space>are<space>no<space>groups<comma><space>it<apos>s<space>not<space>a<space>list<space>attribute<lf><space><space><space><space><space><space><space><space>split_list<space>=<space>self.regex2.split<openparen>list_attr<closeparen><lf><space><space><space><space><space><space><space><space>max_index<space>=<space>len<openparen>split_list<closeparen><space>-<space>1<lf><space><space><space><space><space><space><space><space>#<space>find<space>the<space>last<space>occurence<space>of<space><opencurly>n<closecurly><space>-<gt><space>search<space>backwards<lf><space><space><space><space><space><space><space><space>split_pos<space>=<space>-1<lf><space><space><space><space><space><space><space><space>for<space>i<space>in<space>range<openparen>max_index<comma><space>-1<comma><space>-1<closeparen>:<lf><space><space><space><space><space><space><space><space><space><space><space><space>if<space>split_list<openbracket>i<closebracket><space>==<space>groups<openbracket>-1<closebracket>:<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>split_pos<space>=<space>i<lf><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space><space>break<lf><space><space><space><space><space><space><space><space>if<space>split_pos<space><lt><space>max_index:<lf><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space><openparen>str.join<openparen><apos><apos><comma><space>split_list<openbracket>:split_pos<closebracket><closeparen><comma><space>split_list<openbracket>split_pos<space>+<space>1<closebracket><closeparen><lf><space><space><space><space><space><space><space><space>else:<lf><space><space><space><space><space><space><space><space><space><space><space><space>result<space>=<space><openparen>str.join<openparen><apos><apos><comma><space>split_list<openbracket>:max_index<closebracket><closeparen><comma><space><apos><apos><closeparen><lf><space><space><space><space><space><space><space><space>return<space>result<lf><space><space><space><space><space><space><space><space><lf><space><space><space><space>def<space>close<openparen>self<closeparen>:<lf><space><space><space><space><space><space><space><space>del<space>self OUTPUT PYOUTPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_PythonCaller_OUTPUT"
# -------------------------------------------------------------------------
FACTORY_DEF * TestFactory FACTORY_NAME $(ListKeyValuePairExtractor_WORKSPACE_NAME)_Tester INPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_PythonCaller_OUTPUT" TEST @EvaluateExpression(FDIV,STRING_ENCODED,<at>Value<openparen>_error<closeparen>,$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Tester) NOT_ATTRIBUTE_HAS_VALUE "" ENCODED BOOLEAN_OPERATOR OR OUTPUT PASSED FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Tester_PASSED" OUTPUT FAILED FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Tester_FAILED"
# -------------------------------------------------------------------------
INCLUDE [ set macroLine "MACRO $(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_2_LIST_EXP "; foreach attr [split ""] { set attr [FME_DecodeText $attr]; set attr [regsub "{}$" $attr "{}.*"]; set attr [regsub -all "{}" $attr "\\{\[0-9\]+\\}"]; append macroLine ",^$attr$"; }; puts $macroLine; ]
FACTORY_DEF * TeeFactory FACTORY_NAME $(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_2 INPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Tester_FAILED" OUTPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_2_OUTPUT" @RemoveAttributes(fme_encoded,__key_attr,__val_attr,__attr_conflict_res) @RemoveAttributes(fme_pcre_match"$($(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_2_LIST_EXP)")
# -------------------------------------------------------------------------
INCLUDE [ set macroLine "MACRO $(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_LIST_EXP "; foreach attr [split ""] { set attr [FME_DecodeText $attr]; set attr [regsub "{}$" $attr "{}.*"]; set attr [regsub -all "{}" $attr "\\{\[0-9\]+\\}"]; append macroLine ",^$attr$"; }; puts $macroLine; ]
FACTORY_DEF * TeeFactory FACTORY_NAME $(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover INPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Tester_PASSED" OUTPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_OUTPUT" @RemoveAttributes(fme_encoded,__attr_conflict_res,__key_attr,_error,__val_attr) @RemoveAttributes(fme_pcre_match"$($(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_LIST_EXP)")
FACTORY_DEF * TeeFactory FACTORY_NAME "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Output1505392804 Output Collector" INPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_OUTPUT" OUTPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_Output"
FACTORY_DEF * TeeFactory FACTORY_NAME "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_<Rejected>1505392804 Output Collector" INPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_AttributeRemover_2_OUTPUT" OUTPUT FEATURE_TYPE "$(ListKeyValuePairExtractor_WORKSPACE_NAME)_<Rejected>"
INCLUDE [puts {MACRO WB_CURRENT_CONTEXT $(WB_OLD_CONTEXT_$(ListKeyValuePairExtractor_WORKSPACE_NAME))}]