Skip to content

Commit 74c8765

Browse files
committed
Reorganize so __init__ creates no tmp dir
1 parent 84629f3 commit 74c8765

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/py/kaleido/kaleido.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ def __init__( # noqa: D417, PLR0913 no args/kwargs in description
159159
"or `kaleido.get_chrome_sync()`.",
160160
) from ChromeNotFoundError
161161

162+
# do this during open because it requires close
163+
self._saved_page_arg = page
164+
165+
async def open(self):
166+
"""Build temporary file if we need one."""
167+
page = self._saved_page_arg
168+
del self._saved_page_arg
169+
162170
if isinstance(page, str):
163171
if page.startswith(r"file://") and Path(unquote(urlparse(page).path)):
164172
self._index = page
@@ -178,6 +186,7 @@ def __init__( # noqa: D417, PLR0913 no args/kwargs in description
178186
if not page:
179187
page = PageGenerator(plotly=self._plotlyjs, mathjax=self._mathjax)
180188
page.generate_index(index)
189+
await super().open()
181190

182191
async def _conform_tabs(self, tabs: list[choreo.Tab] | None = None) -> None:
183192
if not tabs:

0 commit comments

Comments
 (0)