Skip to content

Commit 3ee4a92

Browse files
Copilotjacalata
andauthored
Remove deprecated cgi module usage and clean up dead code
Agent-Logs-Url: https://github.com/tableau/server-client-python/sessions/453f920c-7857-4503-ad99-0ccef076d792 Co-authored-by: jacalata <2009720+jacalata@users.noreply.github.com>
1 parent 2d80bd6 commit 3ee4a92

File tree

4 files changed

+6
-30
lines changed

4 files changed

+6
-30
lines changed

tableauserverclient/helpers/headers.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

tableauserverclient/server/endpoint/datasources_endpoint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import Literal, Optional, TYPE_CHECKING, TypedDict, TypeVar, Union, overload
1010
from collections.abc import Iterable, Sequence
1111

12-
from tableauserverclient.helpers.headers import fix_filename
1312
from tableauserverclient.models.dqw_item import DQWItem
1413
from tableauserverclient.server.query import QuerySet
1514

@@ -1025,14 +1024,13 @@ def download_revision(
10251024
with closing(self.get_request(url, parameters={"stream": True})) as server_response:
10261025
m = Message()
10271026
m["Content-Disposition"] = server_response.headers["Content-Disposition"]
1028-
params = m.get_filename(failobj="")
1027+
filename = m.get_filename(failobj="")
10291028
if isinstance(filepath, io_types_w):
10301029
for chunk in server_response.iter_content(1024): # 1KB
10311030
filepath.write(chunk)
10321031
return_path = filepath
10331032
else:
1034-
params = fix_filename(params)
1035-
filename = to_filename(os.path.basename(params))
1033+
filename = to_filename(os.path.basename(filename))
10361034
download_path = make_download_path(filepath, filename)
10371035
with open(download_path, "wb") as f:
10381036
for chunk in server_response.iter_content(1024): # 1KB

tableauserverclient/server/endpoint/flows_endpoint.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from typing import Optional, TYPE_CHECKING, Union
99
from collections.abc import Iterable
1010

11-
from tableauserverclient.helpers.headers import fix_filename
12-
1311
from tableauserverclient.server.endpoint.dqw_endpoint import _DataQualityWarningEndpoint
1412
from tableauserverclient.server.endpoint.endpoint import QuerysetEndpoint, api
1513
from tableauserverclient.server.endpoint.exceptions import InternalServerError, MissingRequiredFieldError
@@ -227,14 +225,13 @@ def download(self, flow_id: str, filepath: Optional[PathOrFileW] = None) -> Path
227225
with closing(self.get_request(url, parameters={"stream": True})) as server_response:
228226
m = Message()
229227
m["Content-Disposition"] = server_response.headers["Content-Disposition"]
230-
params = m.get_filename(failobj="")
228+
filename = m.get_filename(failobj="")
231229
if isinstance(filepath, io_types_w):
232230
for chunk in server_response.iter_content(1024): # 1KB
233231
filepath.write(chunk)
234232
return_path = filepath
235233
else:
236-
params = fix_filename(params)
237-
filename = to_filename(os.path.basename(params))
234+
filename = to_filename(os.path.basename(filename))
238235
download_path = make_download_path(filepath, filename)
239236
with open(download_path, "wb") as f:
240237
for chunk in server_response.iter_content(1024): # 1KB

tableauserverclient/server/endpoint/workbooks_endpoint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from contextlib import closing
77
from pathlib import Path
88

9-
from tableauserverclient.helpers.headers import fix_filename
109
from tableauserverclient.models.permissions_item import PermissionsRule
1110
from tableauserverclient.server.query import QuerySet
1211

@@ -1098,14 +1097,13 @@ def download_revision(
10981097
with closing(self.get_request(url, parameters={"stream": True})) as server_response:
10991098
m = Message()
11001099
m["Content-Disposition"] = server_response.headers["Content-Disposition"]
1101-
params = m.get_filename(failobj="")
1100+
filename = m.get_filename(failobj="")
11021101
if isinstance(filepath, io_types_w):
11031102
for chunk in server_response.iter_content(1024): # 1KB
11041103
filepath.write(chunk)
11051104
return_path = filepath
11061105
else:
1107-
params = fix_filename(params)
1108-
filename = to_filename(os.path.basename(params))
1106+
filename = to_filename(os.path.basename(filename))
11091107
download_path = make_download_path(filepath, filename)
11101108
with open(download_path, "wb") as f:
11111109
for chunk in server_response.iter_content(1024): # 1KB

0 commit comments

Comments
 (0)