Skip to content

Commit cd261a3

Browse files
committed
Merge branch 'development' into add-namespace-samples
2 parents 6518a43 + c8466d4 commit cd261a3

File tree

12 files changed

+65
-95
lines changed

12 files changed

+65
-95
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
paths-ignore:
9+
- 'docs/**'
10+
pull_request:
11+
branches: '*'
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python-version: [3.7, 3.8, 3.9]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install pycodestyle
32+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
33+
- name: Lint with pycodestyle
34+
run: |
35+
pycodestyle tableaudocumentapi test samples
36+
- name: Test
37+
run: |
38+
python setup.py test

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ language: python
22
cache: pip
33

44
python:
5-
- "2.7"
65
- "3.4"
76
- "3.5"
87
- "3.6"
9-
- "pypy"
8+
- "pypy3"
109
# command to install dependencies
1110
install:
1211
- "pip install -e ."

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ For more information, see the documentation:
77

88
<http://tableau.github.io/document-api-python>
99

10-
For more information, see the documentation:
11-
12-
<http://tableau.github.io/document-api-python>
13-
1410
Document API
1511
---------------
1612
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 :)
@@ -33,3 +29,6 @@ Features include:
3329
- Get all fields in use by certain sheets in a workbook
3430

3531
We don't yet support creating files from scratch, adding extracts into workbooks or data sources, or updating field information
32+
33+
34+
As of 2021, this SDK no longer supports Python 2.

docs/docs/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ anyone can add to an issue:
5151

5252
## Fixes, Implementations, and Documentation
5353

54-
For all other things, please submit a PR that includes the fix, documentation, or new code that you are trying to contribute. More information on submitting a PR can be found in the [developer guide](dev-guide.md)
54+
For all other things, please submit a PR that includes the fix, documentation, or new code that you are trying to contribute. More information on this can be found in our [developer guide](http://tableau.github.io/document-api-python/docs/dev-guide)
5555

5656
If the feature is complex or has multiple solutions that could be equally appropriate approaches, it would be helpful to file an issue to discuss the
5757
design trade-offs of each solution before implementing, to allow us to collectively arrive at the best solution, which most likely exists in the middle

publish.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ set -e
55
rm -rf dist
66
python setup.py sdist
77
python setup.py bdist_wheel
8-
python3 setup.py bdist_wheel
98
twine upload dist/*

setup.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
try:
2-
from setuptools import setup
3-
except ImportError:
4-
from distutils.core import setup
5-
1+
from setuptools import setup
2+
63
setup(
74
name='tableaudocumentapi',
85
version='0.6',

tableaudocumentapi/connection.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def __repr__(self):
2828

2929
@classmethod
3030
def from_attributes(cls, server, dbname, username, dbclass, port=None, query_band=None,
31-
initial_sql=None, authentication='', schema='', service=''):
32-
31+
initial_sql=None, authentication=''):
3332
"""Creates a new connection that can be added into a Data Source.
3433
defaults to `''` which will be treated as 'prompt' by Tableau."""
3534

@@ -38,8 +37,6 @@ def from_attributes(cls, server, dbname, username, dbclass, port=None, query_ban
3837
xml.server = server
3938
xml.dbname = dbname
4039
xml.username = username
41-
xml.schema = schema
42-
xml.service = service
4340
xml.dbclass = dbclass
4441
xml.port = port
4542
xml.query_band = query_band
@@ -211,43 +208,3 @@ def initial_sql(self, value):
211208
pass
212209
else:
213210
self._connectionXML.set('one-time-sql', value)
214-
215-
@property
216-
def schema(self):
217-
"""Database schema for the connection. Not the table name."""
218-
return self._schema
219-
220-
@schema.setter
221-
def schema(self, value):
222-
"""
223-
Set the connection's schema property.
224-
225-
Args:
226-
value: New name of the database schema. String.
227-
228-
Returns:
229-
Nothing.
230-
231-
"""
232-
self._schema = value
233-
self._connectionXML.set('schema', value)
234-
235-
@property
236-
def service(self):
237-
"""Database service for the connection. Not the table name."""
238-
return self._service
239-
240-
@service.setter
241-
def service(self, value):
242-
"""
243-
Set the connection's service property.
244-
245-
Args:
246-
value: New name of the database service. String.
247-
248-
Returns:
249-
Nothing.
250-
251-
"""
252-
self._service = value
253-
self._connectionXML.set('service', value)

tableaudocumentapi/datasource.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@
99
from tableaudocumentapi.multilookup_dict import MultiLookupDict
1010
from tableaudocumentapi.xfile import xml_open
1111

12-
########
13-
# This is needed in order to determine if something is a string or not. It is necessary because
14-
# of differences between python2 (basestring) and python3 (str). If python2 support is ever
15-
# dropped, remove this and change the basestring references below to str
16-
try:
17-
basestring
18-
except NameError: # pragma: no cover
19-
basestring = str
20-
########
21-
2212
_ColumnObjectReturnTuple = collections.namedtuple('_ColumnObjectReturnTupleType', ['id', 'object'])
2313

2414

@@ -38,7 +28,7 @@ class FieldDictionary(MultiLookupDict):
3828
def used_by_sheet(self, name):
3929
# If we pass in a string, no need to get complicated, just check to see if name is in
4030
# the field's list of worksheets
41-
if isinstance(name, basestring):
31+
if isinstance(name, str):
4232
return [x for x in self.values() if name in x.worksheets]
4333

4434
# if we pass in a list, we need to check to see if any of the names in the list are in

tableaudocumentapi/xfile.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
import zipfile
66
import xml.etree.ElementTree as ET
77

8-
try:
9-
from distutils2.version import NormalizedVersion as Version
10-
except ImportError:
11-
from distutils.version import LooseVersion as Version
8+
from distutils.version import LooseVersion as Version
129

1310
MIN_SUPPORTED_VERSION = Version("9.0")
1411

@@ -28,7 +25,7 @@ def xml_open(filename, expected_root=None):
2825
# Is the file a zip (.twbx or .tdsx)
2926
if zipfile.is_zipfile(filename):
3027
tree = get_xml_from_archive(filename)
31-
else:
28+
else:
3229
_register_all_namespaces()
3330
tree = ET.parse(filename)
3431

@@ -55,9 +52,11 @@ def temporary_directory(*args, **kwargs):
5552
finally:
5653
shutil.rmtree(d)
5754

58-
def _register_all_namespaces():
55+
56+
def _register_all_namespaces():
5957
# TO DO: should look at the file to find namespaces, not hardcode this one
60-
ET.register_namespace("user","http://www.tableausoftware.com/xml/user")
58+
ET.register_namespace("user", "http://www.tableausoftware.com/xml/user")
59+
6160

6261
def find_file_in_zip(zip_file):
6362
'''Returns the twb/tds file from a Tableau packaged file format. Packaged
@@ -124,9 +123,9 @@ def save_into_archive(xml_tree, filename, new_filename=None):
124123

125124

126125
def _save_file(container_file, xml_tree, new_filename=None):
127-
128-
_register_all_namespaces() # this shouldn't be necessary, should be done on open
129-
126+
127+
_register_all_namespaces() # this shouldn't be necessary, should be done on open
128+
130129
if new_filename is None:
131130
new_filename = container_file
132131

test/assets/index.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@
2727
TWBX_WITH_CACHE_FILES = os.path.join(TEST_DIR, 'Cache.twbx')
2828

2929
COMPLEX_TWB = os.path.join(TEST_DIR, 'filtering.twb')
30-

0 commit comments

Comments
 (0)