diff --git a/README.md b/README.md index 2ed1923..ac00c41 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ If you just import tableau_tools per the following, you will have access to the If you need to use tableau_documents, use the following import statements: from tableau_tools import * - from tableau_documents import * + from tableau_tools.tableau_documents import * ### 0.2 Logger class The Logger class implements useful and verbose logging to a plain text file that all of the other objects can use. You declare a single Logger object, then pass it to the other objects, resulting in a single continuous log file of all actions. diff --git a/__init__.py b/__init__.py index 44e6161..62d9cd9 100644 --- a/__init__.py +++ b/__init__.py @@ -8,4 +8,3 @@ #from .tableau._server_rest import TableauServerRest, TableauServerRest33 from .tableau_rest_api_connection import * from .tableau_server_rest import * -import tableau_documents diff --git a/examples/hyper_api_samples.py b/examples/hyper_api_samples.py index bd985e2..39c7ef7 100644 --- a/examples/hyper_api_samples.py +++ b/examples/hyper_api_samples.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from tableau_tools import * -from tableau_documents import * -from tableau_documents.hyper_file_generator import HyperFileGenerator +from tableau_tools.tableau_documents import * +from tableau_tools.tableau_documents.hyper_file_generator import HyperFileGenerator import pyodbc import sys diff --git a/examples/replicate_site_structure_sample.py b/examples/replicate_site_structure_sample.py index 6412d9e..41b814a 100644 --- a/examples/replicate_site_structure_sample.py +++ b/examples/replicate_site_structure_sample.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from tableau_tools import * -from tableau_documents import * +from tableau_tools.tableau_documents import * import time import os diff --git a/examples/template_publish_sample.py b/examples/template_publish_sample.py index f6ce242..cb34e9d 100644 --- a/examples/template_publish_sample.py +++ b/examples/template_publish_sample.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from tableau_tools import * -from tableau_documents import * +from tableau_tools.tableau_documents import * import datetime import os @@ -90,6 +90,22 @@ def promote_from_dev_to_test(logger_obj=None): # promote_from_dev_to_test(logger) +# This function shows changing out a Hyper file in an existing packaged workbook +# It assumes you have used the Hyper API at least once to generate a Hyper file, then used Tableau Desktop to connect +# to that Hyper file, and saved a packaged file (TWBX or TDSX) with that file +def hyper_api_swap_example(logger_obj = None): + newly_built_hyper_filename = 'Replacement Hyper File.hyper' + t_file = TableauFileManager.open(filename='Packaged File.tdsx', logger_obj=logger_obj) + filenames = t_file.get_filenames_in_package() + for filename in filenames: + # Find my Hyper file + if filename.lower.find('.hyper') != -1: + t_file.set_file_for_replacement(filename_in_package=filename, + replacement_filname_on_disk=newly_built_hyper_filename) + break # Breaking here on a TDSX, but you could do a whole mapping I suppose to replace multiples in a TDSX + + t_file.save_new_file(new_filename_no_extension='Updated Packaged File') + # This function shows publishing multiple workbooks from a single project # which will also publish across any published data sources that are linked # This is a complex algorithm but is necessary for working with published data sources diff --git a/examples/test_suite_tableau_documents.py b/examples/test_suite_tableau_documents.py index 3395171..82898ee 100644 --- a/examples/test_suite_tableau_documents.py +++ b/examples/test_suite_tableau_documents.py @@ -1,5 +1,5 @@ from tableau_tools import * -from tableau_documents import * +from tableau_tools.tableau_documents import * # # WIP and will be more fully built out in the future. See template_publish_sample.py for other uses as well as the README diff --git a/setup.py b/setup.py index 94409f4..b8f740f 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,9 @@ setup( name='tableau_tools', python_requires='>=3.6', - version='5.0.4', - packages=['tableau_tools', 'tableau_tools.tableau_rest_api', 'tableau_tools.tableau_documents', 'tableau_tools.examples'], + version='5.0.6', + packages=['tableau_tools', 'tableau_tools.tableau_rest_api', 'tableau_tools.tableau_documents', + 'tableau_tools.examples', 'tableau_tools.tableau_rest_api.methods'], url='https://github.com/bryantbhowell/tableau_tools', license='', author='Bryant Howell', diff --git a/tableau_documents/tableau_columns.py b/tableau_documents/tableau_columns.py index 1ce9111..379cb32 100644 --- a/tableau_documents/tableau_columns.py +++ b/tableau_documents/tableau_columns.py @@ -7,7 +7,7 @@ from tableau_tools.logger import Logger from tableau_tools.logging_methods import LoggingMethods -from tableau_documents.tableau_parameters import TableauParameter +from .tableau_parameters import TableauParameter class TableauColumns(LoggingMethods): diff --git a/tableau_documents/tableau_datasource.py b/tableau_documents/tableau_datasource.py index 8f102dd..2de475f 100644 --- a/tableau_documents/tableau_datasource.py +++ b/tableau_documents/tableau_datasource.py @@ -10,10 +10,10 @@ from tableau_tools.tableau_exceptions import * from tableau_tools.logger import Logger from tableau_tools.logging_methods import LoggingMethods -from tableau_documents.tableau_connection import TableauConnection -from tableau_documents.tableau_document import TableauDocument -from tableau_documents.tableau_columns import TableauColumns -from tableau_documents.table_relations import TableRelations +from .tableau_connection import TableauConnection +from .tableau_document import TableauDocument +from .tableau_columns import TableauColumns +from .table_relations import TableRelations # Meant to represent a TDS file, does not handle the file opening diff --git a/tableau_documents/tableau_parameters.py b/tableau_documents/tableau_parameters.py index a0b158e..b00a844 100644 --- a/tableau_documents/tableau_parameters.py +++ b/tableau_documents/tableau_parameters.py @@ -15,7 +15,6 @@ def __init__(self, parameter_xml: Optional[ET.Element] = None, parameter_number: logger_obj: Optional[Logger] = None, name: Optional[str] = None, datatype: Optional[str] = None, current_value: Optional[str] = None): - TableauBase.__init__(self) self.logger = logger_obj self._aliases = False self._values_list = None diff --git a/tableau_rest_api/methods/metadata.py b/tableau_rest_api/methods/metadata.py index e2fd963..989b362 100644 --- a/tableau_rest_api/methods/metadata.py +++ b/tableau_rest_api/methods/metadata.py @@ -1,5 +1,5 @@ from .rest_api_base import * -from tableau_rest_api.permissions import DatabasePermissions35, TablePermissions35 +from ..permissions import DatabasePermissions35, TablePermissions35 import json diff --git a/tableau_rest_api/methods/schedule.py b/tableau_rest_api/methods/schedule.py index 9893132..3149b20 100644 --- a/tableau_rest_api/methods/schedule.py +++ b/tableau_rest_api/methods/schedule.py @@ -1,4 +1,6 @@ from .rest_api_base import * + + class ScheduleMethods(): def __init__(self, rest_api_base: TableauRestApiBase): self.rest_api_base = rest_api_base diff --git a/tableau_rest_api/methods/subscription.py b/tableau_rest_api/methods/subscription.py index c4a5d06..13d7726 100644 --- a/tableau_rest_api/methods/subscription.py +++ b/tableau_rest_api/methods/subscription.py @@ -1,5 +1,7 @@ -from .rest_api_base import * from requests.exceptions import HTTPError + +from .rest_api_base import * + class SubscriptionMethods(): def __init__(self, rest_api_base: TableauRestApiBase): self.rest_api_base = rest_api_base