forked from tableau/document-api-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathextract.py
More file actions
39 lines (30 loc) · 1.18 KB
/
extract.py
File metadata and controls
39 lines (30 loc) · 1.18 KB
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
from tableaudocumentapi import DBColumn, Relation, Connection, Refresh
class Extract(object):
"""A class representing extracts inside Data Sources."""
def __init__(self, extract_xml):
"""Extract is usually instantiated by passing in extract XML
from a Data Source.
"""
self._extractXML = extract_xml
self._enabled = extract_xml.get('enabled')
self._units = extract_xml.get('units')
self._connection = list(map(Connection, self._extractXML.findall('./connection')))
self._relation = list(map(Relation, self._extractXML.findall('./connection/relation')))
self._cols = list(map(DBColumn, self._extractXML.findall('./connection/cols/*')))
self._refresh = list(map(Refresh, self._extractXML.findall('./connection/refresh')))
@property
def enabled(self):
return self._enabled
@property
def units(self):
return self._units
@property
def connection(self):
return self._connection[0]
def has_refresh(self):
return len(self._refresh) > 0
@property
def refresh(self):
if not self.has_refresh():
return None
return self._refresh[0]