How to use the tableaudocumentapi.xfile.TableauInvalidFileException function in tableaudocumentapi

To help you get started, we’ve selected a few tableaudocumentapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tableau / document-api-python / test / bvt.py View on Github external
def test_exception_when_datasource_given_twbx(self):
        with self.assertRaises(TableauInvalidFileException):
            ds = Datasource.from_file(TABLEAU_10_TWBX)
github tableau / document-api-python / test / bvt.py View on Github external
def test_exception_when_workbook_given_tdsx(self):
        with self.assertRaises(TableauInvalidFileException):
            wb = Workbook(TABLEAU_10_TDSX)
github tableau / document-api-python / test / bvt.py View on Github external
def test_exception_when_datasource_given_twbx(self):
        with self.assertRaises(TableauInvalidFileException):
            ds = Datasource.from_file(TABLEAU_10_TWBX)
github tableau / document-api-python / test / bvt.py View on Github external
def test_exception_when_workbook_given_tdsx(self):
        with self.assertRaises(TableauInvalidFileException):
            wb = Workbook(TABLEAU_10_TDSX)
github tableau / document-api-python / tableaudocumentapi / xfile.py View on Github external
# Is the file a zip (.twbx or .tdsx)
    if zipfile.is_zipfile(filename):
        tree = get_xml_from_archive(filename)
    else:
        tree = ET.parse(filename)

    # Is the file a supported version
    tree_root = tree.getroot()
    file_version = Version(tree_root.attrib.get('version', '0.0'))

    if file_version < MIN_SUPPORTED_VERSION:
        raise TableauVersionNotSupportedException(file_version)

    # Does the root tag match the object type (workbook or data source)
    if expected_root and (expected_root != tree_root.tag):
        raise TableauInvalidFileException(
            "'{}'' is not a valid '{}' file".format(filename, expected_root))

    return tree