forked from tableau/document-api-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmetadata_record.py
More file actions
77 lines (60 loc) · 2.19 KB
/
metadata_record.py
File metadata and controls
77 lines (60 loc) · 2.19 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
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
class MetadataRecord(object):
"""A class representing metadata record (in the datasource-connection or in the datasource-extract."""
def __init__(self, metadata_recordxml):
"""Instantiate metadata record.
"""
self._mtdrecord = metadata_recordxml
self._remote_name = self._mtdrecord.find('remote-name').text
self._local_name = self._mtdrecord.find('local-name').text if self.mtd_record.find('local_name') else ""
self._remote_alias = self._mtdrecord.find('remote-alias').text
@property
def mtd_record(self):
"""The metadata record."""
return self._mtdrecord
@property
def remote_name(self):
"""The remote name of the field to which metadata record belongs."""
return self._remote_name
@property
def local_name(self):
"""The local name of the field to which metadata record belongs."""
return self._local_name.strip('[').strip(']')
@property
def remote_alias(self):
"""The remote alias of the field to which metadata record belongs"""
return self._remote_alias
@remote_name.setter
def remote_name(self, value):
"""
Sets the new remote name for the metadata record.
Args:
value: new remote name. String.
Returns:
Nothing.
"""
self._remote_name = value
self._mtdrecord.find('remote-name').text = value
@local_name.setter
def local_name(self, value):
"""
Sets the new remote name for the metadata record.
Args:
value: new remote name. String.
Returns:
Nothing.
"""
# local name is in brackets in the XML
value_processed = value.strip('[').strip(']')
self._local_name = value_processed
self._mtdrecord.find('local-name').text = "[{}]".format(value_processed)
@remote_alias.setter
def remote_alias(self, value):
"""
Sets the new remote name for the metadata record.
Args:
value: new remote name. String.
Returns:
Nothing.
"""
self._remote_alias = value
self._mtdrecord.find('remote-alias').text = value