quickquery 0.1.2__tar.gz → 0.1.3__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.
- {quickquery-0.1.2 → quickquery-0.1.3}/PKG-INFO +1 -1
- {quickquery-0.1.2 → quickquery-0.1.3}/pyproject.toml +1 -1
- {quickquery-0.1.2 → quickquery-0.1.3}/quickquery/live.py +10 -9
- {quickquery-0.1.2 → quickquery-0.1.3}/.gitignore +0 -0
- {quickquery-0.1.2 → quickquery-0.1.3}/.python-version +0 -0
- {quickquery-0.1.2 → quickquery-0.1.3}/LICENSE +0 -0
- {quickquery-0.1.2 → quickquery-0.1.3}/README.md +0 -0
- {quickquery-0.1.2 → quickquery-0.1.3}/quickquery/__init__.py +0 -0
- {quickquery-0.1.2 → quickquery-0.1.3}/quickquery/core.py +0 -0
- {quickquery-0.1.2 → quickquery-0.1.3}/quickquery/utils.py +0 -0
|
@@ -36,8 +36,8 @@ class _SessionBase:
|
|
|
36
36
|
recycle: RecycleEvery | None = None,
|
|
37
37
|
) -> None:
|
|
38
38
|
self._recycle = recycle or RecycleEvery()
|
|
39
|
-
self._browser_options =
|
|
40
|
-
self._context_options =
|
|
39
|
+
self._browser_options = browser_options or {}
|
|
40
|
+
self._context_options = context_options or {}
|
|
41
41
|
self._browser = None
|
|
42
42
|
self._context = None
|
|
43
43
|
self._page: Page | None = None
|
|
@@ -47,7 +47,7 @@ class _SessionBase:
|
|
|
47
47
|
def page(self) -> Page:
|
|
48
48
|
if not self._entered:
|
|
49
49
|
raise RuntimeError('with ブロックの外で page() を呼べません')
|
|
50
|
-
if self.
|
|
50
|
+
if self._browser is None:
|
|
51
51
|
self._open_browser()
|
|
52
52
|
elif (b := self._recycle.browser) and self._page_calls % b == 0:
|
|
53
53
|
self._close_browser()
|
|
@@ -67,7 +67,7 @@ class _SessionBase:
|
|
|
67
67
|
def _close_page(self) -> None:
|
|
68
68
|
if self._page is not None:
|
|
69
69
|
self._page.close()
|
|
70
|
-
|
|
70
|
+
self._page = None
|
|
71
71
|
|
|
72
72
|
def _open_context(self) -> None:
|
|
73
73
|
self._context = self._browser.new_context(**self._context_options)
|
|
@@ -77,7 +77,7 @@ class _SessionBase:
|
|
|
77
77
|
self._close_page()
|
|
78
78
|
if self._context is not None:
|
|
79
79
|
self._context.close()
|
|
80
|
-
|
|
80
|
+
self._context = None
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
class PatchrightSession(_SessionBase):
|
|
@@ -111,8 +111,8 @@ class PatchrightSession(_SessionBase):
|
|
|
111
111
|
self._close_browser()
|
|
112
112
|
self._pw.stop()
|
|
113
113
|
self._pw = None
|
|
114
|
-
self._entered = False
|
|
115
114
|
self._page_calls = 0
|
|
115
|
+
self._entered = False
|
|
116
116
|
|
|
117
117
|
def _open_browser(self) -> None:
|
|
118
118
|
self._browser = self._pw.chromium.launch(**self._browser_options)
|
|
@@ -153,19 +153,20 @@ class CamoufoxSession(_SessionBase):
|
|
|
153
153
|
if not self._entered:
|
|
154
154
|
return
|
|
155
155
|
self._close_browser()
|
|
156
|
-
self._entered = False
|
|
157
156
|
self._page_calls = 0
|
|
157
|
+
self._entered = False
|
|
158
158
|
|
|
159
159
|
def _open_browser(self) -> None:
|
|
160
|
+
fox = Camoufox(**self._browser_options)
|
|
160
161
|
self._stack = ExitStack()
|
|
161
|
-
self._browser = self._stack.enter_context(
|
|
162
|
+
self._browser = self._stack.enter_context(fox)
|
|
162
163
|
self._open_context()
|
|
163
164
|
|
|
164
165
|
def _close_browser(self) -> None:
|
|
165
166
|
self._close_context()
|
|
166
167
|
if self._stack is not None:
|
|
167
168
|
self._stack.close()
|
|
168
|
-
|
|
169
|
+
self._stack = None
|
|
169
170
|
self._browser = None
|
|
170
171
|
|
|
171
172
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|