Skip to content

refactor request_options, add language param #1481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 11, 2024
Merged
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
check_untyped_defs = false
disable_error_code = [
'misc',
# tableauserverclient\server\endpoint\datasources_endpoint.py:48: error: Cannot assign multiple types to name "FilePath" without an explicit "Type[...]" annotation [misc]
'annotation-unchecked' # can be removed when check_untyped_defs = true
]
files = ["tableauserverclient", "test", "samples"]
show_error_codes = true
ignore_missing_imports = true # defusedxml library has no types
no_implicit_reexport = true
implicit_optional = true

[tool.pytest.ini_options]
testpaths = ["test"]
Expand Down
14 changes: 9 additions & 5 deletions samples/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def main():
"--csv", dest="type", action="store_const", const=("populate_csv", "CSVRequestOptions", "csv", "csv")
)
# other options shown in explore_workbooks: workbook.download, workbook.preview_image

parser.add_argument(
"--language", help="Text such as 'Average' will appear in this language. Use values like fr, de, es, en"
)
parser.add_argument("--workbook", action="store_true")

parser.add_argument("--file", "-f", help="filename to store the exported data")
Expand Down Expand Up @@ -74,16 +76,18 @@ def main():
populate = getattr(server.workbooks, populate_func_name)

option_factory = getattr(TSC, option_factory_name)
options: TSC.PDFRequestOptions = option_factory()

if args.filter:
options = option_factory().vf(*args.filter.split(":"))
else:
options = None
options = options.vf(*args.filter.split(":"))

if args.language:
options.language = args.language

if args.file:
filename = args.file
else:
filename = f"out.{extension}"
filename = f"out-{options.language}.{extension}"

populate(item, options)
with open(filename, "wb") as f:
Expand Down
48 changes: 26 additions & 22 deletions tableauserverclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
PermissionsRule,
PersonalAccessTokenAuth,
ProjectItem,
Resource,
RevisionItem,
ScheduleItem,
SiteItem,
ServerInfoItem,
SubscriptionItem,
TableauItem,
TableItem,
TableauAuth,
Target,
Expand Down Expand Up @@ -66,66 +68,68 @@
)

__all__ = [
"get_versions",
"DEFAULT_NAMESPACE",
"BackgroundJobItem",
"BackgroundJobItem",
"ColumnItem",
"ConnectionCredentials",
"ConnectionItem",
"CSVRequestOptions",
"CustomViewItem",
"DQWItem",
"DailyInterval",
"DataAlertItem",
"DatabaseItem",
"DataFreshnessPolicyItem",
"DatasourceItem",
"DEFAULT_NAMESPACE",
"DQWItem",
"ExcelRequestOptions",
"FailedSignInError",
"FavoriteItem",
"FileuploadItem",
"Filter",
"FlowItem",
"FlowRunItem",
"FileuploadItem",
"get_versions",
"GroupItem",
"GroupSetItem",
"HourlyInterval",
"ImageRequestOptions",
"IntervalItem",
"JobItem",
"JWTAuth",
"LinkedTaskFlowRunItem",
"LinkedTaskItem",
"LinkedTaskStepItem",
"MetricItem",
"MissingRequiredFieldError",
"MonthlyInterval",
"NotSignedInError",
"Pager",
"PaginationItem",
"PDFRequestOptions",
"Permission",
"PermissionsRule",
"PersonalAccessTokenAuth",
"ProjectItem",
"RequestOptions",
"Resource",
"RevisionItem",
"ScheduleItem",
"SiteItem",
"Server",
"ServerInfoItem",
"ServerResponseError",
"SiteItem",
"Sort",
"SubscriptionItem",
"TableItem",
"TableauAuth",
"TableauItem",
"TableItem",
"Target",
"TaskItem",
"UserItem",
"ViewItem",
"VirtualConnectionItem",
"WebhookItem",
"WeeklyInterval",
"WorkbookItem",
"CSVRequestOptions",
"ExcelRequestOptions",
"ImageRequestOptions",
"PDFRequestOptions",
"RequestOptions",
"MissingRequiredFieldError",
"NotSignedInError",
"ServerResponseError",
"Filter",
"Pager",
"Server",
"Sort",
"LinkedTaskItem",
"LinkedTaskStepItem",
"LinkedTaskFlowRunItem",
"VirtualConnectionItem",
]
Loading
Loading