@@ -120,11 +120,11 @@ def _extract_federated_connections(self):
120
120
connections = list (map (Connection , self ._dsxml .findall ('.//named-connections/named-connection/*' )))
121
121
# 'sqlproxy' connections (Tableau Server Connections) are not embedded into named-connection elements
122
122
# extract them manually for now
123
- connections .extend (map (Connection , self ._dsxml .findall ("./connection[@class='sqlproxy']" )))
123
+ connections .extend (map (Connection , self ._dsxml .findall (".// connection[@class='sqlproxy']" )))
124
124
return connections
125
125
126
126
def _extract_legacy_connection (self ):
127
- return list (map (Connection , self ._dsxml .findall ('connection' )))
127
+ return list (map (Connection , self ._dsxml .children ('connection' )))
128
128
129
129
def get_connections (self ):
130
130
"""Find and return all connections based on file format version."""
@@ -156,11 +156,13 @@ def __init__(self, dsxml, filename=None):
156
156
self ._caption = self ._datasourceXML .get ('caption' , '' )
157
157
self ._connection_parser = ConnectionParser (self ._datasourceXML , version = self ._version )
158
158
self ._connections = self ._connection_parser .get_connections ()
159
+ self ._db_columns = self ._get_db_column_objects ()
160
+ self ._extract_columns = self ._get_extract_column_objects ()
159
161
self ._fields = None
162
+ self ._extract_fields = None
160
163
self ._parameter_parser = ParameterParser (self ._datasourceXML , version = self ._version )
161
164
self ._parameters = self ._parameter_parser .get_parameters ()
162
165
self ._columns = None
163
- self ._db_columns = self ._get_db_column_objects ()
164
166
165
167
self ._relations = list (map (Relation , self ._datasourceXML .findall ("./connection[@class='federated']/relation" )))
166
168
self ._extracts = list (map (Extract , self ._datasourceXML .findall ("./extract" )))
@@ -255,6 +257,12 @@ def fields(self):
255
257
self ._fields = self ._get_all_fields ()
256
258
return self ._fields
257
259
260
+ @property
261
+ def extract_fields (self ):
262
+ if not self ._extract_fields :
263
+ self ._extract_fields = self ._get_extract_fields ()
264
+ return self ._extract_fields
265
+
258
266
@property
259
267
def columns (self ):
260
268
if not self ._columns :
@@ -281,17 +289,29 @@ def _get_all_fields(self):
281
289
282
290
return FieldDictionary ({k : v for k , v in field_objects })
283
291
292
+ def _get_extract_fields (self ):
293
+ self ._extract_metadata_objects = (x for x in self ._get_extract_metadata_objects ())
294
+ return FieldDictionary ({k : v for k , v in self ._extract_metadata_objects })
295
+
284
296
def _get_metadata_objects (self ):
285
297
return (_column_object_from_metadata_xml (xml )
286
298
for xml in self ._datasourceTree .findall (".//metadata-record[@class='column']" ))
287
299
300
+ def _get_extract_metadata_objects (self ):
301
+ return (_column_object_from_metadata_xml (xml )
302
+ for xml in self ._datasourceTree .findall (".//extract/connection/metadata-records/metadata-record[@class='column']" ))
303
+
288
304
def _get_column_objects (self ):
289
305
return [_column_object_from_column_xml (self ._datasourceTree , xml )
290
- for xml in self ._datasourceTree .findall ('.// column' )]
306
+ for xml in self ._datasourceTree .findall ('./column' )]
291
307
292
308
def _get_db_column_objects (self ):
293
309
return dict ([_db_column_object_from_db_column_xml (self ._datasourceTree , xml )
294
- for xml in self ._datasourceTree .findall ('./connection/cols/map' )])
310
+ for xml in self ._datasourceTree .findall ('.//connection/cols/map' )])
311
+
312
+ def _get_extract_column_objects (self ):
313
+ return dict ([_db_column_object_from_db_column_xml (self ._datasourceTree , xml )
314
+ for xml in self ._datasourceTree .findall ('.//extract/connection/cols/map' )])
295
315
296
316
def has_extract (self ):
297
317
return len (self ._extracts ) > 0 and self ._extracts [0 ].enabled == 'true'
0 commit comments