Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Publish to PyPi


on:
workflow_dispatch:
push:
Expand All @@ -11,24 +10,23 @@ jobs:
name: Build dist files for PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.13
- name: Build dist files
run: >
python -m pip install --upgrade pip && pip install -e .[build] &&
python setup.py build &&
python setup.py sdist --formats=gztar
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2
uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2
uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2
with:
password: ${{ secrets.PYPI_API_TOKEN }}

64 changes: 30 additions & 34 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,50 @@ name: Python package
on:
push:
paths-ignore:
- 'docs/**'
- "docs/**"
pull_request:
branches: '*'
branches: "*"

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test
run: |
python setup.py test


- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test
run: |
python -m unittest discover -v

lint:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.9]
python-version: [3.13]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pycodestyle
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with pycodestyle
run: |
pycodestyle tableaudocumentapi test samples

- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pycodestyle
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with pycodestyle
run: |
pycodestyle tableaudocumentapi test samples
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 011 (November 2022)
* Remove extraneous debug print statements

## 010 (June 2022)
* Add service/schema attributes
Expand All @@ -6,7 +8,7 @@
* Add attribute for hidden field

## 09 (December 2021)
* Pypi upgraded to Python3
* PyPI upgraded to Python3

## 08 (October 2021)
* See dashboards in a workbook
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#ECCN:Open Source
#GUSINFO:Open Source,Open Source Workflow
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# document-api-python
[![Tableau Supported](https://img.shields.io/badge/Support%20Level-Tableau%20Supported-53bd92.svg)](https://www.tableau.com/support-levels-it-and-developer-tools)
[![As-Is](https://img.shields.io/badge/Support%20Level-As--Is-e8762c.svg)](https://www.tableau.com/support-levels-it-and-developer-tools)

This repo contains Python source and example files for the Tableau Document API.

For more information, see the documentation:

<https://tableau.github.io/document-api-python>

Document API
---------------
The Document API provides a supported way to programmatically make updates to Tableau workbook and data source files. If you've been making changes to these file types by directly updating the XML--that is, by XML hacking--this SDK is for you :)
This repo contains Python source and example files for the Tableau Document API.
The Document API provides a useful but *unsupported* way to programmatically make updates to Tableau workbook and data source files. If you've been making changes to these file types by directly updating the XML--that is, by XML hacking--this SDK is for you :) Get help from other users on the [Tableau Community Forums](https://community.tableau.com/s/topic/0TO4T000000SF3sWAG/document-api).

Features include:
- Support for TWB, TWBX, TDE and TDSX files starting roughly back to Tableau 9.x
Expand All @@ -27,8 +23,9 @@ Features include:
- Get all fields in a data source
- Get all fields in use by certain sheets in a workbook

- It *doesn't* support creating files from scratch, adding extracts into workbooks or data sources, or updating field information. As of 2021, this SDK no longer supports Python 2.

For Hyper files, take a look at the [Tableau Hyper API](https://help.tableau.com/current/api/hyper_api/en-us/index.html).

We don't support creating files from scratch, adding extracts into workbooks or data sources, or updating field information
For more information, see the [Document API documentation](https://tableau.github.io/document-api-python)

As of 2021, this SDK no longer supports Python 2.
24 changes: 17 additions & 7 deletions docs/_includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<!-- Footer -->
<footer>
<div class="row">
<hr class="footer-hr">
<p>This site is open source. Suggestions and pull requests are welcome on our <a href="https://github.com/tableau/document-api-python">GitHub page</a>.</p>
<p><a href="https://www.tableau.com/en-us/legal" class="aLegal">LEGAL</a> <a href="https://www.tableau.com/en-us/privacy" class="aLegal">PRIVACY</a> &copy; 2003&ndash;<script>document.write(new Date().getFullYear())</script> TABLEAU SOFTWARE LLC. ALL RIGHTS RESERVED</p>
<sub>Documentation last generated on: {{ site.time }}</sub>
</div>
</footer>
<hr class="footer-hr">
<nav aria-label="Footer Navigation">
<ul class="footer-links">
<li><a href="https://www.salesforce.com/company/legal/">Legal</a></li>
<li><a href="https://www.salesforce.com/company/legal/sfdc-website-terms-of-service/">Terms of Service</a></li>
<li><a href="https://www.salesforce.com/company/privacy/">Privacy Information</a></li>
<li><a href="https://www.salesforce.com/company/legal/disclosure/">Responsible Disclosure</a></li>
<li><a href="https://trust.salesforce.com/">Trust</a></li>
<li><a href="#" data-ignore-geolocation="true" class="optanon-toggle-display">Cookie Preferences</a></li>
<li><a href="https://www.salesforce.com/form/other/privacy-request/">Your Privacy Choices</a></li>
</ul>
<p class="copyRight">This site is open source. Suggestions and pull requests are welcome on our <a href="https://github.com/tableau/document-api-python">GitHub page</a>.</p>
<p class="copyRight">&copy; Copyright <script>document.write(new Date().getFullYear())</script> Salesforce, Inc. <a href="https://www.salesforce.com/company/legal/tmcusageguidelines/">All rights reserved.</a> Various trademarks held by their respective owners.
Salesforce, Inc. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States</p>
<sub>Documentation last generated on: {{ site.time }}</sub></p>
</nav>
</footer>
8 changes: 8 additions & 0 deletions docs/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
<link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
<link rel="stylesheet" href="{{ site.baseurl }}/css/github-highlight.css">

<!-- OneTrust Cookies Consent Notice start for tableau.github.io -->
<script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js" type="text/javascript" charset="UTF-8" data-domain-script="019321c1-4b7e-7313-9372-ddbd938f50ea" ></script>
<script type="text/javascript">
function OptanonWrapper() { }
</script>
<!-- OneTrust Cookies Consent Notice end for tableau.github.io -->


<script src="{{ site.baseurl }}/js/redirect-to-search.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
Expand Down
37 changes: 37 additions & 0 deletions docs/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,40 @@ html {
word-spacing: 8px;
padding-right: 8px;
}

.copyRight {
font-size: 12px;
}

.footer-links {
display: flex;
justify-content: center;
list-style: none;
padding: 0;
flex-wrap: wrap;
}

.footer-links li {
margin: 0 15px;
}

.footer-links a {
text-decoration: none;
transition: color 0.3s;
font-size: 12px;
}

.footer-links a:hover {
text-decoration: underline;
}

/* One Trust Cookie Manager
-------------------- */
#ot-pc-content, .ot-title-cntr, .ot-pc-footer {
font-size: 1.6rem;
}

#ot-pc-footer {
font-size: 1.4rem;
}

4 changes: 3 additions & 1 deletion docs/docs/api-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Saves any changes to the workbook to a new file specified by the `new_file` para

`self.shapes` Returns a list of strings with the names of shapes found in the workbook.

`self.dashboards:` Returns a list of strings with the names of the dashboards found in the workbook

## Datasources
```python
class Datasource(dsxml, filename=None)
Expand All @@ -66,7 +68,7 @@ A class representing Tableau Data Sources, embedded in workbook files or in TDS

`self.name` Returns string with the name of datasource.

`self.version` Returns string of daatasource's version.
`self.version` Returns string of datasource's version.

`self.caption` Returns string of user defined name of datasource if exists.

Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ layout: home
# Document API Overview
This repo contains Python source and example files for the Tableau Document API.

The Document API provides a supported way to programmatically make updates to Tableau workbook and data source files. If you've been making changes to these file types by directly updating the XML--that is, by XML hacking--this SDK is for you.
The Document API provides an *unsupported* way to programmatically make updates to Tableau workbook and data source files. If you've been making changes to these file types by directly updating the XML--that is, by XML hacking--this SDK is for you.

Features include:

Expand All @@ -32,6 +32,6 @@ Features include:
- Get all fields in a data source
- Get all fields in use by certain sheets in a workbook

For Hyper files, take a look a the [Tableau Hyper API](https://help.tableau.com/current/api/hyper_api/en-us/index.html).
For Hyper files, take a look a the [Tableau Hyper API](https://tableau.github.io/hyper-db/docs/).

We don't yet support creating files from scratch, adding extracts into workbooks or data sources, or updating field information.
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
lxml
setuptools
packaging
pycodestyle
2 changes: 1 addition & 1 deletion samples/preserve-namespaces/preserve-namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def assertContainsUserNamespace(filename):
lineCount += 1
found = doc_beginning_excerpt.rfind("xmlns:user=")
print(doc_beginning_excerpt[found:found+10])
assert(found >= 0)
assert (found >= 0)


############################################################
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='tableaudocumentapi',
version='0.10',
version='0.11',
author='Tableau',
author_email='github@tableau.com',
url='https://github.com/tableau/document-api-python',
Expand Down
1 change: 0 additions & 1 deletion tableaudocumentapi/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def _initialize_from_metadata_xml(self, xmldata):
self._apply_attribute(xmldata, field_name,
lambda x: getattr(xmldata.find('.//{}'.format(metadata_name)), 'text', None),
read_name=metadata_name)
print(metadata_name, field_name)
self.apply_metadata(xmldata)

@classmethod
Expand Down