diff --git a/setup.py b/setup.py index eac07082..7380dd42 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ long_description=readme, long_description_content_type='text/markdown', name="tableau_utilities", - version="2.2.11", + version="2.2.12", requires_python=">=3.8", packages=[ 'tableau_utilities', diff --git a/tableau_utilities/tableau_file/tableau_file.py b/tableau_utilities/tableau_file/tableau_file.py index 8d55d56b..575e38d3 100644 --- a/tableau_utilities/tableau_file/tableau_file.py +++ b/tableau_utilities/tableau_file/tableau_file.py @@ -151,6 +151,7 @@ def __init__(self, file_path): self.folders_common: tfo.FoldersCommon = self.__get_section(tfo.FoldersCommon) self.date_options: tfo.DateOptions = self.__get_section(tfo.DateOptions) self.extract: tfo.Extract = self.__get_section(tfo.Extract) + self.layout: tfo.Layout = self.__get_section(tfo.Layout) def __delattr__(self, attr): section = getattr(self, attr) @@ -172,6 +173,7 @@ def sections(self): yield self.folders_common yield self.date_options yield self.extract + yield self.layout @staticmethod def __remove_section_from_parent(parent, tag) -> list[tuple[int, ET.Element]]: @@ -224,6 +226,7 @@ def enforce_column(self, column, folder_name=None, remote_name=None): - Create the folder if it doesn't exist - Updating the metadata local-name to map to the column name - Adding the column mapping to the mapping cols, if it doesn't exist + - Displaying the folders and sorting columns alphabetically Args: column (tfo.Column): The TableFile Column object @@ -255,6 +258,11 @@ def enforce_column(self, column, folder_name=None, remote_name=None): elif not folder: self.folders_common.folder.add(tfo.Folder(name=folder_name, folder_item=[folder_item])) + # Set display to show folders + self.layout.update(show_structure='true') + + + # If a remote_name was provided, and the column is not a Tableau Calculation - enforce metadata if not remote_name or column.calculation: return None diff --git a/tableau_utilities/tableau_file/tableau_file_objects.py b/tableau_utilities/tableau_file/tableau_file_objects.py index 7935f803..f5d29bf1 100644 --- a/tableau_utilities/tableau_file/tableau_file_objects.py +++ b/tableau_utilities/tableau_file/tableau_file_objects.py @@ -1071,6 +1071,30 @@ def dict(self): return dictionary +@dataclass +class Layout(TableauFileObject): + """ The Layout Tableau file object """ + dim_percentage: str = None + measure_percentage: str = None + dim_ordering: str = None # ordinal or alphabetic + measure_ordering: str = None # ordinal or alphabetic + show_structure: bool = None + tag: str = 'layout' + + def dict(self): + dictionary = dict() + if self.dim_percentage is not None: + dictionary['@dim-percentage'] = self.dim_percentage + if self.measure_percentage is not None: + dictionary['@measure-percentage'] = self.measure_percentage + if self.dim_ordering is not None: + dictionary['@dim-ordering'] = self.dim_ordering + if self.measure_ordering is not None: + dictionary['@measure-ordering'] = self.measure_ordering + if self.show_structure is not None: + dictionary['@show-structure'] = str(self.show_structure).lower() + return dictionary + @dataclass class Aliases(TableauFileObject): """ The Aliases Tableau file object """