How to use the tableaudocumentapi.xfile.TableauVersionNotSupportedException 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_82_workbook_throws_exception(self):
        with self.assertRaises(TableauVersionNotSupportedException):
            wb = Workbook(TABLEAU_82_TWB)
github tableau / document-api-python / test / bvt.py View on Github external
def test_82_workbook_throws_exception(self):
        with self.assertRaises(TableauVersionNotSupportedException):
            wb = Workbook(TABLEAU_82_TWB)
github tableau / document-api-python / tableaudocumentapi / xfile.py View on Github external
def xml_open(filename, expected_root=None):
    """Opens the provided 'filename'. Handles detecting if the file is an archive,
    detecting the document version, and validating the root tag."""

    # 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