From bcd73c1bb7d684c1103d9d0c7dcde272e94879ea Mon Sep 17 00:00:00 2001 From: Charley Peng Date: Tue, 16 Aug 2016 06:05:07 +1000 Subject: [PATCH 1/4] Update README.md (#71) CLANotRequired --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a6534d2..588fb14 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Features include: - Database Name - Getting Field information from data sources and workbooks - Get all fields in a data source - - Get all feilds in use by certain sheets in a workbook + - Get all fields in use by certain sheets in a workbook We don't yet support creating files from scratch, adding extracts into workbooks or data sources, or updating field information @@ -45,7 +45,7 @@ Download the `.zip` file that contains the SDK. Unzip the file and then run the pip install -e ``` -#### Installing the Development Version From Git +#### Installing the Development Version from Git *Only do this if you know you want the development version, no guarantee that we won't break APIs during development* @@ -74,7 +74,7 @@ sourceWB.datasources[0].connections[0].username = "benl" sourceWB.save() ``` -With Data Integration in Tableau 10, a data source can have multiple connections. To access the connections simply index them like you would datasources +With Data Integration in Tableau 10, a data source can have multiple connections. To access the connections simply index them like you would datasources. ```python from tableaudocumentapi import Workbook @@ -104,6 +104,6 @@ sourceWB.save() -###Examples +###[Examples](Examples) -The downloadable package contains several example scripts that show more detailed usage of the Document API +The downloadable package contains several example scripts that show more detailed usage of the Document API. From 3fc962852ae52c12dcc9548f4d5f0261e975b9ce Mon Sep 17 00:00:00 2001 From: MiguelSR Date: Thu, 8 Sep 2016 13:23:06 +0200 Subject: [PATCH 2/4] Fix bug in Python2 when column name has non-ascii characters. --- tableaudocumentapi/datasource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tableaudocumentapi/datasource.py b/tableaudocumentapi/datasource.py index dd3d5c5..69318ed 100644 --- a/tableaudocumentapi/datasource.py +++ b/tableaudocumentapi/datasource.py @@ -31,7 +31,7 @@ def _get_metadata_xml_for_field(root_xml, field_name): if "'" in field_name: field_name = sax.escape(field_name, {"'": "'"}) - xpath = ".//metadata-record[@class='column'][local-name='{}']".format(field_name) + xpath = u".//metadata-record[@class='column'][local-name='{}']".format(field_name) return root_xml.find(xpath) From 473d613d84b9a02608bd135d1df11577ebfcb510 Mon Sep 17 00:00:00 2001 From: MiguelSR Date: Thu, 8 Sep 2016 14:39:02 +0200 Subject: [PATCH 3/4] Fix get description method for Python 2 when description has non-ASCII characters --- tableaudocumentapi/field.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tableaudocumentapi/field.py b/tableaudocumentapi/field.py index 63cc72c..355694e 100644 --- a/tableaudocumentapi/field.py +++ b/tableaudocumentapi/field.py @@ -1,4 +1,5 @@ import functools +import sys import xml.etree.ElementTree as ET @@ -199,4 +200,9 @@ def _read_description(xmldata): if description is None: return None - return u'{}'.format(ET.tostring(description, encoding='utf-8')) # This is necessary for py3 support + description_string = ET.tostring(description, encoding='utf-8') + # Format expects a unicode string so in Python 2 we have to do the explicit conversion + if sys.version_info[0] == 2: + description_string = description_string.decode('utf-8') + + return u'{}'.format(description_string) # This is necessary for py3 support From 8de7409e9d27d9c15f4038363bae312a540578e5 Mon Sep 17 00:00:00 2001 From: MiguelSR Date: Mon, 19 Sep 2016 10:06:00 +0200 Subject: [PATCH 4/4] Small refactor, check type of string instead of python version --- tableaudocumentapi/field.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tableaudocumentapi/field.py b/tableaudocumentapi/field.py index 355694e..65ce78d 100644 --- a/tableaudocumentapi/field.py +++ b/tableaudocumentapi/field.py @@ -1,5 +1,4 @@ import functools -import sys import xml.etree.ElementTree as ET @@ -202,7 +201,7 @@ def _read_description(xmldata): description_string = ET.tostring(description, encoding='utf-8') # Format expects a unicode string so in Python 2 we have to do the explicit conversion - if sys.version_info[0] == 2: + if isinstance(description_string, bytes): description_string = description_string.decode('utf-8') - return u'{}'.format(description_string) # This is necessary for py3 support + return description_string