pytableau 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. pytableau-0.1.0/.github/workflows/ci.yml +60 -0
  2. pytableau-0.1.0/.github/workflows/docs.yml +46 -0
  3. pytableau-0.1.0/.github/workflows/publish.yml +29 -0
  4. pytableau-0.1.0/.gitignore +37 -0
  5. pytableau-0.1.0/LICENSE +21 -0
  6. pytableau-0.1.0/PKG-INFO +177 -0
  7. pytableau-0.1.0/PLAN.md +874 -0
  8. pytableau-0.1.0/README.md +133 -0
  9. pytableau-0.1.0/docs/api/index.md +31 -0
  10. pytableau-0.1.0/docs/cookbook/index.md +120 -0
  11. pytableau-0.1.0/docs/index.md +12 -0
  12. pytableau-0.1.0/docs/quickstart.md +40 -0
  13. pytableau-0.1.0/mkdocs.yml +31 -0
  14. pytableau-0.1.0/pyproject.toml +108 -0
  15. pytableau-0.1.0/src/pytableau/__init__.py +93 -0
  16. pytableau-0.1.0/src/pytableau/_compat.py +46 -0
  17. pytableau-0.1.0/src/pytableau/_version.py +1 -0
  18. pytableau-0.1.0/src/pytableau/cli/__init__.py +15 -0
  19. pytableau-0.1.0/src/pytableau/cli/main.py +137 -0
  20. pytableau-0.1.0/src/pytableau/constants.py +212 -0
  21. pytableau-0.1.0/src/pytableau/core/__init__.py +38 -0
  22. pytableau-0.1.0/src/pytableau/core/dashboard.py +337 -0
  23. pytableau-0.1.0/src/pytableau/core/datasource.py +470 -0
  24. pytableau-0.1.0/src/pytableau/core/fields.py +398 -0
  25. pytableau-0.1.0/src/pytableau/core/filters.py +331 -0
  26. pytableau-0.1.0/src/pytableau/core/formatting.py +7 -0
  27. pytableau-0.1.0/src/pytableau/core/workbook.py +352 -0
  28. pytableau-0.1.0/src/pytableau/core/worksheet.py +464 -0
  29. pytableau-0.1.0/src/pytableau/data/__init__.py +23 -0
  30. pytableau-0.1.0/src/pytableau/data/bridge.py +157 -0
  31. pytableau-0.1.0/src/pytableau/data/extract.py +114 -0
  32. pytableau-0.1.0/src/pytableau/data/types.py +81 -0
  33. pytableau-0.1.0/src/pytableau/exceptions.py +144 -0
  34. pytableau-0.1.0/src/pytableau/inspect/__init__.py +19 -0
  35. pytableau-0.1.0/src/pytableau/inspect/catalog.py +100 -0
  36. pytableau-0.1.0/src/pytableau/inspect/diff.py +7 -0
  37. pytableau-0.1.0/src/pytableau/inspect/lineage.py +121 -0
  38. pytableau-0.1.0/src/pytableau/inspect/report.py +119 -0
  39. pytableau-0.1.0/src/pytableau/package/__init__.py +12 -0
  40. pytableau-0.1.0/src/pytableau/package/assets.py +7 -0
  41. pytableau-0.1.0/src/pytableau/package/manager.py +146 -0
  42. pytableau-0.1.0/src/pytableau/py.typed +0 -0
  43. pytableau-0.1.0/src/pytableau/server/__init__.py +13 -0
  44. pytableau-0.1.0/src/pytableau/server/client.py +174 -0
  45. pytableau-0.1.0/src/pytableau/server/workflows.py +67 -0
  46. pytableau-0.1.0/src/pytableau/templates/__init__.py +24 -0
  47. pytableau-0.1.0/src/pytableau/templates/engine.py +131 -0
  48. pytableau-0.1.0/src/pytableau/templates/library/__init__.py +58 -0
  49. pytableau-0.1.0/src/pytableau/templates/library/bar_chart.twb +28 -0
  50. pytableau-0.1.0/src/pytableau/templates/library/heatmap.twb +29 -0
  51. pytableau-0.1.0/src/pytableau/templates/library/kpi_dashboard.twb +25 -0
  52. pytableau-0.1.0/src/pytableau/templates/library/line_chart.twb +28 -0
  53. pytableau-0.1.0/src/pytableau/templates/library/map.twb +28 -0
  54. pytableau-0.1.0/src/pytableau/templates/library/scatter_plot.twb +29 -0
  55. pytableau-0.1.0/src/pytableau/templates/library/treemap.twb +29 -0
  56. pytableau-0.1.0/src/pytableau/templates/mapping.py +65 -0
  57. pytableau-0.1.0/src/pytableau/xml/__init__.py +7 -0
  58. pytableau-0.1.0/src/pytableau/xml/differ.py +7 -0
  59. pytableau-0.1.0/src/pytableau/xml/discovery/__init__.py +11 -0
  60. pytableau-0.1.0/src/pytableau/xml/discovery/controlled_diff.py +43 -0
  61. pytableau-0.1.0/src/pytableau/xml/discovery/corpus.py +53 -0
  62. pytableau-0.1.0/src/pytableau/xml/engine.py +130 -0
  63. pytableau-0.1.0/src/pytableau/xml/proxy.py +37 -0
  64. pytableau-0.1.0/src/pytableau/xml/schemas/__init__.py +11 -0
  65. pytableau-0.1.0/src/pytableau/xml/schemas/base.py +7 -0
  66. pytableau-0.1.0/src/pytableau/xml/schemas/v2022.py +7 -0
  67. pytableau-0.1.0/src/pytableau/xml/schemas/v2023.py +7 -0
  68. pytableau-0.1.0/src/pytableau/xml/schemas/v2024.py +7 -0
  69. pytableau-0.1.0/src/pytableau/xml/schemas/v2025.py +7 -0
  70. pytableau-0.1.0/src/pytableau/xml/writer.py +7 -0
  71. pytableau-0.1.0/tests/__init__.py +1 -0
  72. pytableau-0.1.0/tests/test_extract.py +68 -0
  73. pytableau-0.1.0/tests/test_hyper_bridge.py +46 -0
  74. pytableau-0.1.0/tests/test_hyper_query.py +25 -0
  75. pytableau-0.1.0/tests/test_imports.py +199 -0
  76. pytableau-0.1.0/tests/test_metadata_sync.py +63 -0
  77. pytableau-0.1.0/tests/test_phase6_and_server_features.py +305 -0
  78. pytableau-0.1.0/tests/test_stage1_read_and_stage2_mutation.py +403 -0
  79. pytableau-0.1.0/tests/test_type_mapping.py +26 -0
  80. pytableau-0.1.0/tests/test_workbook_io.py +86 -0
@@ -0,0 +1,60 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ name: Lint & type-check
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.12"
20
+
21
+ - name: Install dev dependencies
22
+ run: pip install -e ".[dev]"
23
+
24
+ - name: Ruff lint
25
+ run: ruff check src tests
26
+
27
+ - name: Ruff format check
28
+ run: ruff format --check src tests
29
+
30
+ - name: Mypy
31
+ run: mypy src/pytableau
32
+
33
+ test:
34
+ name: Tests (Python ${{ matrix.python-version }})
35
+ runs-on: ubuntu-latest
36
+ strategy:
37
+ fail-fast: false
38
+ matrix:
39
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
40
+
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+
44
+ - name: Set up Python ${{ matrix.python-version }}
45
+ uses: actions/setup-python@v5
46
+ with:
47
+ python-version: ${{ matrix.python-version }}
48
+
49
+ - name: Install package with dev dependencies
50
+ run: pip install -e ".[dev]"
51
+
52
+ - name: Run tests
53
+ run: pytest --cov=pytableau --cov-report=term-missing
54
+
55
+ - name: Upload coverage report
56
+ if: matrix.python-version == '3.12'
57
+ uses: actions/upload-artifact@v4
58
+ with:
59
+ name: coverage-report
60
+ path: .coverage
@@ -0,0 +1,46 @@
1
+ name: Docs
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ concurrency:
15
+ group: github-pages
16
+ cancel-in-progress: true
17
+
18
+ jobs:
19
+ publish:
20
+ runs-on: ubuntu-latest
21
+ environment:
22
+ name: github-pages
23
+ url: ${{ steps.deploy.outputs.page_url }}
24
+
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+
28
+ - name: Set up Python
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: "3.12"
32
+
33
+ - name: Install docs dependencies
34
+ run: pip install mkdocs mkdocstrings[python]
35
+
36
+ - name: Build docs
37
+ run: mkdocs build
38
+
39
+ - name: Upload docs site
40
+ uses: actions/upload-pages-artifact@v3
41
+ with:
42
+ path: site
43
+
44
+ - name: Deploy to GitHub Pages
45
+ id: deploy
46
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,29 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+ id-token: write
9
+
10
+ jobs:
11
+ pypi:
12
+ runs-on: ubuntu-latest
13
+ environment: release
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.12"
21
+
22
+ - name: Install build tooling
23
+ run: python -m pip install --upgrade pip build
24
+
25
+ - name: Build distribution artifacts
26
+ run: python -m build
27
+
28
+ - name: Publish to PyPI
29
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,37 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ .Python
7
+
8
+ # Distribution / packaging
9
+ dist/
10
+ build/
11
+ *.egg-info/
12
+ *.egg
13
+
14
+ # Virtual environments
15
+ .venv/
16
+ venv/
17
+ env/
18
+
19
+ # Testing / coverage
20
+ .pytest_cache/
21
+ .coverage
22
+ coverage.xml
23
+ htmlcov/
24
+
25
+ # Type checking
26
+ .mypy_cache/
27
+ .ruff_cache/
28
+
29
+ # IDE
30
+ .vscode/
31
+ .idea/
32
+ *.swp
33
+ *.swo
34
+
35
+ # OS
36
+ .DS_Store
37
+ Thumbs.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brian Weisberg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytableau
3
+ Version: 0.1.0
4
+ Summary: The unified Python SDK for Tableau workbook engineering
5
+ Project-URL: Homepage, https://github.com/brianlwb/pytableau
6
+ Project-URL: Repository, https://github.com/brianlwb/pytableau
7
+ Project-URL: Bug Tracker, https://github.com/brianlwb/pytableau/issues
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: data,hyper,tableau,twb,twbx,visualization,workbook
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: lxml>=4.9
23
+ Provides-Extra: all
24
+ Requires-Dist: pandas>=2.0; extra == 'all'
25
+ Requires-Dist: pantab>=5.0; extra == 'all'
26
+ Requires-Dist: tableauhyperapi>=0.0.19; extra == 'all'
27
+ Requires-Dist: tableauserverclient>=0.30; extra == 'all'
28
+ Provides-Extra: dev
29
+ Requires-Dist: click>=8.0; extra == 'dev'
30
+ Requires-Dist: lxml-stubs; extra == 'dev'
31
+ Requires-Dist: mypy>=1.8; extra == 'dev'
32
+ Requires-Dist: pre-commit>=3.0; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
34
+ Requires-Dist: pytest>=8.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.3; extra == 'dev'
36
+ Provides-Extra: hyper
37
+ Requires-Dist: pantab>=5.0; extra == 'hyper'
38
+ Requires-Dist: tableauhyperapi>=0.0.19; extra == 'hyper'
39
+ Provides-Extra: pandas
40
+ Requires-Dist: pandas>=2.0; extra == 'pandas'
41
+ Provides-Extra: server
42
+ Requires-Dist: tableauserverclient>=0.30; extra == 'server'
43
+ Description-Content-Type: text/markdown
44
+
45
+ # pytableau
46
+
47
+ > **What pandas did for tabular data, pytableau does for Tableau workbooks.**
48
+
49
+ `pytableau` is the unified Python SDK for Tableau workbook engineering. It brings every layer of Tableau workbook manipulation — data, connections, semantic model, presentation, packaging, and server lifecycle — under one coherent, Pythonic API.
50
+
51
+ ## Why pytableau?
52
+
53
+ The Tableau Python ecosystem is fragmented. Tableau/Salesforce maintains several narrow libraries, each covering a single concern:
54
+
55
+ | Library | Layer | Limitation |
56
+ |---------|-------|-----------|
57
+ | `tableaudocumentapi` | Connection XML | No calc fields, no viz edits, abandoned 2021 |
58
+ | `tableauhyperapi` | `.hyper` data files | No XML awareness |
59
+ | `pantab` | DataFrame ↔ `.hyper` bridge | No XML awareness |
60
+ | `tableauserverclient` | Server REST API | No local file manipulation |
61
+
62
+ `pytableau` wraps and integrates all of them behind a single API.
63
+
64
+ ## Install
65
+
66
+ ```bash
67
+ # Core (XML + ZIP only — no optional dependencies)
68
+ pip install pytableau
69
+
70
+ # With Hyper / extract support
71
+ pip install "pytableau[hyper]"
72
+
73
+ # With pandas convenience methods
74
+ pip install "pytableau[pandas]"
75
+
76
+ # With Tableau Server/Cloud integration
77
+ pip install "pytableau[server]"
78
+
79
+ # Everything
80
+ pip install "pytableau[all]"
81
+ ```
82
+
83
+ ## Quick Start
84
+
85
+ ### Open and inspect a workbook
86
+
87
+ ```python
88
+ from pytableau import Workbook
89
+
90
+ wb = Workbook.open("sales_dashboard.twbx")
91
+
92
+ print(wb.version) # "2024.1"
93
+ print(wb.datasources.names) # ["Sales Data", "Parameters"]
94
+ print(wb.worksheets.names) # ["Revenue by Region", "Trend"]
95
+ print(wb.dashboards.names) # ["Executive Summary"]
96
+
97
+ catalog = wb.catalog()
98
+ for field in catalog.calculated_fields:
99
+ print(f"{field.caption}: {field.formula}")
100
+ ```
101
+
102
+ ### Swap database connections (CI/CD promotion)
103
+
104
+ ```python
105
+ from pytableau import Workbook
106
+
107
+ wb = Workbook.open("report.twbx")
108
+ for ds in wb.datasources:
109
+ for conn in ds.connections:
110
+ conn.server = "prod-db.corp.com"
111
+ conn.dbname = "analytics_prod"
112
+ wb.save_as("report_prod.twbx")
113
+ ```
114
+
115
+ ### Inject a DataFrame
116
+
117
+ ```python
118
+ from pytableau import Workbook
119
+ import pandas as pd
120
+
121
+ wb = Workbook.open("template.twbx")
122
+ df = pd.read_csv("fresh_data.csv")
123
+ wb.datasources["Sales Data"].hyper.from_dataframe(df)
124
+ wb.save_as("refreshed_report.twbx")
125
+ ```
126
+
127
+ ### Generate a workbook from a template
128
+
129
+ ```python
130
+ from pytableau import Workbook
131
+ import pandas as pd
132
+
133
+ df = pd.read_csv("q4_revenue.csv")
134
+
135
+ wb = Workbook.from_template("bar_chart")
136
+ wb.datasources["__PLACEHOLDER_DS__"].hyper.from_dataframe(df)
137
+ wb.template.map_fields({
138
+ "__DIMENSION__": "Product Category",
139
+ "__MEASURE__": "Revenue",
140
+ "__COLOR__": "Region",
141
+ })
142
+ wb.parameters["__PARAM_TITLE__"].value = "Q4 2025 Revenue"
143
+ wb.save_as("q4_report.twbx")
144
+ ```
145
+
146
+ ### CLI
147
+
148
+ ```bash
149
+ pytableau inspect workbook.twbx
150
+ pytableau diff before.twb after.twb
151
+ pytableau swap workbook.twb --server prod-db.corp.com --db analytics_prod
152
+ ```
153
+
154
+ ## Development Status
155
+
156
+ | Phase | Description | Status |
157
+ |-------|-------------|--------|
158
+ | 0 | Foundation: scaffolding, packaging, constants | In Progress |
159
+ | 1 | Read & Inspect: parse any `.twb`/`.twbx` | Planned |
160
+ | 2 | Connection & Field Mutation | Planned |
161
+ | 3 | Data Layer: `.hyper` integration | Planned |
162
+ | 4 | Template Engine | Planned |
163
+ | 5 | Server Integration | Planned |
164
+ | 6 | Advanced Features | Planned |
165
+
166
+ ## Design Principles
167
+
168
+ 1. **Layer cake, not monolith.** Each Tableau layer maps to a distinct submodule. Engage at any abstraction level.
169
+ 2. **Batteries included, escape hatches available.** The Pythonic API covers 90% of use cases; raw `lxml` nodes are always accessible.
170
+ 3. **Template-first for presentation.** Build a viz in Desktop, then parameterize it with pytableau.
171
+ 4. **Fail loud, fail early.** Validate XML mutations before writing — a corrupt `.twb` is the worst outcome.
172
+ 5. **Dependency-light by default.** Core requires only `lxml`. Hyper, server, and pandas are optional extras.
173
+ 6. **Version-aware.** Track Tableau Desktop version; warn on incompatible XML.
174
+
175
+ ## License
176
+
177
+ MIT — see [LICENSE](LICENSE)