From c327dea03eba9b860985dc116063fbd9290b7ae0 Mon Sep 17 00:00:00 2001 From: Bryant Howell Date: Fri, 3 Jan 2020 15:02:58 -0600 Subject: [PATCH] Fixed the type checking --- tableau_rest_api/published_content.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tableau_rest_api/published_content.py b/tableau_rest_api/published_content.py index 9aa64a2..589f68b 100644 --- a/tableau_rest_api/published_content.py +++ b/tableau_rest_api/published_content.py @@ -950,18 +950,20 @@ def are_permissions_locked(self) -> bool: def lock_permissions(self): self.start_log_block() if self.permissions_locked is False: + # This allows type checking without importing the class if(type(self.t_rest_api).__name__.find('TableauRestApiConnection') != -1): self.t_rest_api.update_project(self.luid, locked_permissions=True) - if(type(self.t_rest_api).__name__.find('TableauServerRest') != -1): + else: self.t_rest_api.projects.update_project(self.luid, locked_permissions=True) self.end_log_block() def unlock_permissions(self): self.start_log_block() if self.permissions_locked is True: + # This allows type checking without importing the class if(type(self.t_rest_api).__name__.find('TableauRestApiConnection') != -1): self.t_rest_api.update_project(self.luid, locked_permissions=False) - if(type(self.t_rest_api).__name__.find('TableauServerRest') != -1): + else: self.t_rest_api.projects.update_project(self.luid, locked_permissions=False) self.end_log_block() @@ -1047,12 +1049,12 @@ def parent_project_luid(self) -> str: def query_child_projects(self) -> ET.Element: self.start_log_block() + # This allows type checking without importing the class if (type(self.t_rest_api).__name__.find('TableauRestApiConnection') != -1): projects = self.t_rest_api.query_projects() - elif(type(self.t_rest_api).__name__.find('TableauServerRest') != -1): - projects = self.t_rest_api.projects.query_projects() else: - raise InvalidOptionException('t_rest_api needs to be either TableauRestApiConnection or TableauServerRest descended') + projects = self.t_rest_api.projects.query_projects() + child_projects = projects.findall('.//t:project[@parentProjectId="{}"]'.format(self.luid), self.t_rest_api.ns_map) self.end_log_block() return child_projects