Skip to content

Commit e3d36eb

Browse files
committed
add remove dashboard
1 parent 447e452 commit e3d36eb

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tableaudocumentapi/workbook.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,26 @@ def __get_section(self, name):
165165
return elt
166166
raise KeyError(name)
167167

168+
def remove_dashboard_by_name(self, name: str) -> Element:
169+
"""Remove dashboard identified by 'name',
170+
171+
Returns: removed dashboard
172+
173+
Raises: KeyError if dashboard not in document
174+
"""
175+
dashboards = self.__get_section("dashboards")
176+
dashboard = None
177+
for elt in dashboards:
178+
if elt.attrib['name'] == name:
179+
dashboard = elt
180+
break
181+
else:
182+
raise KeyError(f"dashboard {name} is not in document")
183+
dashboards.remove(dashboard)
184+
assert dashboard not in dashboards
185+
self._remove_window(name)
186+
return dashboard
187+
168188
def remove_worksheet_by_name(self, name: str) -> Element:
169189
"""Remove worksheet identified by 'name',
170190

0 commit comments

Comments
 (0)