FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
document-api-python/tableaudocumentapi/relation.py at master · tailsdotcom/document-api-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
tailsdotcom
/
document-api-python
Public
forked from
tableau/document-api-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
document-api-python
/
tableaudocumentapi
/
relation.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
138 lines (109 loc) · 3.28 KB
Breadcrumbs
document-api-python
/
tableaudocumentapi
/
relation.py
Copy path
File metadata and controls
138 lines (109 loc) · 3.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
tableaudocumentapi
import
BaseObject
class
Expression
(
BaseObject
):
def
__init__
(
self
,
expxml
):
self
.
_expressionXML
=
expxml
self
.
_op
=
expxml
.
get
(
'op'
)
self
.
_expressions
=
self
.
_extract_expressions
()
or
None
def
_extract_expressions
(
self
):
return
list
(
map
(
Expression
,
self
.
_expressionXML
.
findall
(
'./expression'
)))
@
property
def
op
(
self
):
return
self
.
_op
@
property
def
expressions
(
self
):
return
self
.
_expressions
def
to_dict
(
self
):
base
=
{
'op'
:
self
.
op
}
if
self
.
expressions
:
base
[
'expressions'
]
=
[
exp
.
to_dict
()
for
exp
in
self
.
expressions
]
return
base
class
Clause
(
BaseObject
):
def
__init__
(
self
,
clxml
):
self
.
_clauseXML
=
clxml
self
.
_type
=
clxml
.
get
(
'type'
)
self
.
_expression
=
self
.
_extract_expression
()
def
_extract_expression
(
self
):
expxml
=
self
.
_clauseXML
.
find
(
'./expression'
)
if
expxml
is
not
None
:
return
Expression
(
expxml
)
else
:
return
None
@
property
def
type
(
self
):
return
self
.
_type
@
property
def
expression
(
self
):
return
self
.
_expression
def
to_dict
(
self
):
return
{
'type'
:
self
.
type
,
'expression'
:
self
.
expression
.
to_dict
()
}
class
Relation
(
BaseObject
):
"""A class representing relations inside Connections."""
def
__init__
(
self
,
relxml
):
self
.
_relationXML
=
relxml
self
.
_type
=
relxml
.
get
(
'type'
)
self
.
_connection
=
relxml
.
get
(
'connection'
)
self
.
_name
=
relxml
.
get
(
'name'
)
self
.
_table
=
relxml
.
get
(
'table'
)
self
.
_text
=
self
.
_extract_text
()
self
.
_clause
=
self
.
_extract_clause
()
self
.
_relation
=
self
.
_extract_relations
()
def
_extract_clause
(
self
):
clxml
=
self
.
_relationXML
.
find
(
'./clause'
)
if
clxml
is
not
None
:
return
Clause
(
clxml
)
else
:
return
None
def
_extract_relations
(
self
):
relxmls
=
self
.
_relationXML
.
findall
(
'./relation'
)
if
relxmls
:
return
list
(
map
(
Relation
,
relxmls
))
else
:
return
None
def
_extract_text
(
self
):
text
=
None
if
self
.
_relationXML
.
text
:
if
not
self
.
_relationXML
.
text
.
isspace
():
text
=
self
.
_relationXML
.
text
return
text
@
property
def
type
(
self
):
return
self
.
_type
@
property
def
name
(
self
):
return
self
.
_name
@
property
def
connection
(
self
):
return
self
.
_connection
@
property
def
table
(
self
):
return
self
.
_table
@
property
def
text
(
self
):
return
self
.
_text
@
property
def
clause
(
self
):
return
self
.
_clause
@
property
def
relation
(
self
):
return
self
.
_relation
def
_base_dict
(
self
):
base_attrs
=
[
'type'
,
'name'
,
'connection'
,
'table'
,
'text'
]
return
self
.
_to_dict
(
base_attrs
=
base_attrs
)
def
to_dict
(
self
):
to_dict_attrs
=
[
'clause'
]
to_dict_list_attrs
=
[
'relation'
]
base
=
self
.
_base_dict
()
base
.
update
(
self
.
_to_dict
(
to_dict_attrs
=
to_dict_attrs
,
to_dict_list_attrs
=
to_dict_list_attrs
,
)
)
return
base
Back
|
FazBrowse Home
|
New Git URL