Skip to content

Commit 880c848

Browse files
committed
Add function to get list of worksheet names
Get worksheet names, but by defualt exclude hidden worksheets.
1 parent 3306af7 commit 880c848

10 files changed

Lines changed: 429 additions & 485 deletions

File tree

BUILD.bazel

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle")
22
load("@pypi//:requirements.bzl", "all_whl_requirements")
3-
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
43
load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")
4+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
55
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
66
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
77

88
compile_pip_requirements(
99
name = "requirements",
1010
srcs = ["pyproject.toml"],
11-
requirements_darwin="requirements_darwin.txt",
12-
requirements_linux="requirements_linux.txt",
11+
requirements_darwin = "requirements_darwin.txt",
12+
requirements_linux = "requirements_linux.txt",
13+
requirements_txt = "requirements.txt",
1314
)
1415

1516
# This rule fetches the metadata for python packages we depend on. That data is
@@ -63,20 +64,18 @@ gazelle(
6364

6465
# gazelle:exclude samples
6566
# gazelle:python_ignore_files setup.py
66-
# gazelle:resolve py lxml.etree @pypi//lxml
6767
# gazelle:python_binary_naming_convention $package_name$
6868
# gazelle:python_library_naming_convention $package_name$
6969

70-
7170
# Publishing
7271

7372
py_wheel(
7473
name = "wheel",
7574
distribution = "tableaudocumentapi_ntnx",
7675
homepage = "https://github.com/nutanix-corp/ng-common-utilities/tree/tableaudocumentapi_ntnx/tableaudocumentapi_ntnx",
77-
version = '0.11.1',
78-
deps = ["//tableaudocumentapi:tableaudocumentapi"],
7976
requires = [
80-
"lxml"
77+
"lxml",
8178
],
79+
version = "0.11.1",
80+
deps = ["//tableaudocumentapi"],
8281
)

MODULE.bazel.lock

Lines changed: 137 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gazelle_python.yaml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,62 @@
44
# bazel run //:gazelle_python_manifest.update
55

66
manifest:
7-
modules_mapping: {}
7+
modules_mapping:
8+
IPython: ipython
9+
asttokens: asttokens
10+
backports: backports.tarfile
11+
certifi: certifi
12+
charset_normalizer: charset_normalizer
13+
click: click
14+
click_completion: click_completion
15+
click_default_group: click_default_group
16+
cucumber_tag_expressions: cucumber_tag_expressions
17+
ddc459050edb75a05942__mypyc: tomli
18+
decorator: decorator
19+
docutils: docutils
20+
executing: executing
21+
id: id
22+
idna: idna
23+
importlib_metadata: importlib_metadata
24+
ipython_pygments_lexers: ipython_pygments_lexers
25+
jaraco.classes: jaraco.classes
26+
jaraco.context: jaraco.context
27+
jaraco.functools: jaraco.functools
28+
jedi: jedi
29+
jinja2: jinja2
30+
keyring: keyring
31+
lxml: lxml
32+
markdown_it: markdown_it_py
33+
markupsafe: MarkupSafe
34+
matplotlib_inline: matplotlib_inline
35+
mdurl: mdurl
36+
more_itertools: more_itertools
37+
nh3: nh3
38+
packaging: packaging
39+
parso: parso
40+
pexpect: pexpect
41+
pluggy: pluggy
42+
pprintpp: pprintpp
43+
prompt_toolkit: prompt_toolkit
44+
ptyprocess: ptyprocess
45+
pure_eval: pure_eval
46+
pygments: pygments
47+
readme_renderer: readme_renderer
48+
requests: requests
49+
requests_toolbelt: requests_toolbelt
50+
rfc3986: rfc3986
51+
rich: rich
52+
shellingham: shellingham
53+
six: six
54+
stack_data: stack_data
55+
tomli: tomli
56+
traitlets: traitlets
57+
twine: twine
58+
typing_extensions: typing_extensions
59+
urllib3: urllib3
60+
ward: ward
61+
wcwidth: wcwidth
62+
zipp: zipp
863
pip_repository:
964
name: pypi
10-
integrity: 745d8c975f02ab21130991aa2f26519c2a9c68235981f021380ed5e1945d0d73
65+
integrity: e80d37e224056e922a98d7fc2db08be95496f95137ebadc6df4a2f9d4123b0a2

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ dependencies = [
55
"ipython",
66
"lxml",
77
"twine",
8+
"ward",
89
]

requirements.txt

Lines changed: 1 addition & 430 deletions
Large diffs are not rendered by default.

requirements_darwin.txt

Lines changed: 183 additions & 38 deletions
Large diffs are not rendered by default.

tableaudocumentapi/workbook.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,23 @@ def remove_dashboard_by_name(self, name: str) -> Element:
185185
self._remove_window(name)
186186
return dashboard
187187

188+
def worksheet_names(self, hidden=False):
189+
"""Get names of worksheets
190+
191+
By default the names of hidden worksheets are not returned. Use hidden=True to see all worksheets.
192+
"""
193+
windows = {}
194+
for elt in self.__get_section("windows"):
195+
windows[elt.attrib["name"]] = elt
196+
names = []
197+
for name in self._worksheets:
198+
window = windows[name]
199+
hidden = window.attrib.get("hidden")
200+
if hidden and hidden == 'true':
201+
continue
202+
names.append(name)
203+
return names
204+
188205
def remove_worksheet_by_name(self, name: str) -> Element:
189206
"""Remove worksheet identified by 'name',
190207

test/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,14 @@ py_test(
6666
"//test/assets",
6767
],
6868
)
69+
70+
py_test(
71+
name = "test_nutanix",
72+
srcs = ["test_nutanix.py", "runner.py"],
73+
main = "runner.py",
74+
deps = [
75+
"//tableaudocumentapi",
76+
"@pypi//ward",
77+
],
78+
data = ["//test/assets:workbooks"]
79+
)

test/assets/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ py_library(
88
],
99
visibility = ["//:__subpackages__"],
1010
)
11+
12+
13+
filegroup(
14+
name="workbooks",
15+
srcs = glob(["*.twb", "*.twbx"]),
16+
visibility = ["//:__subpackages__"]
17+
)

test/test_nutanix.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from ward import test
2+
3+
from tableaudocumentapi import Workbook
4+
5+
@test("only show visible worksheets")
6+
def _():
7+
wb = Workbook("test/assets/sr-backlog.twb")
8+
assert wb.worksheet_names() == ['Sum SR State']

0 commit comments

Comments
 (0)