From 8d37aa079e448544e1e35386b064960d025c6b34 Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 18 Oct 2024 00:24:55 +0800 Subject: [PATCH] =?UTF-8?q?4.1.0.10=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E9=87=8D=E5=91=BD=E5=90=8D=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=EF=BC=9BSettings.locate=5Fsuffixes=5Flist=E6=94=B9=E4=B8=BASet?= =?UTF-8?q?tings.suffixes=5Flist=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 2 +- DrissionPage/_functions/cookies.py | 2 +- DrissionPage/_functions/settings.py | 11 ++++++++--- DrissionPage/_functions/settings.pyi | 10 ++++------ DrissionPage/_pages/session_page.py | 2 +- DrissionPage/_units/setter.py | 1 + 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index 4d2b44b..314a6ed 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -12,4 +12,4 @@ from ._pages.chromium_page import ChromiumPage from ._pages.session_page import SessionPage from ._pages.web_page import WebPage -__version__ = '4.1.0.9' +__version__ = '4.1.0.10' diff --git a/DrissionPage/_functions/cookies.py b/DrissionPage/_functions/cookies.py index 1a645f2..7092909 100644 --- a/DrissionPage/_functions/cookies.py +++ b/DrissionPage/_functions/cookies.py @@ -92,7 +92,7 @@ def set_browser_cookies(browser, cookies): def set_tab_cookies(page, cookies): - suffixes_list = f"file:///{Settings.locate_suffixes_list}" + suffixes_list = f"file:///{Settings.suffixes_list_path}" for cookie in cookies_to_tuple(cookies): cookie = format_cookie(cookie) diff --git a/DrissionPage/_functions/settings.py b/DrissionPage/_functions/settings.py index 6a4de1e..0645efc 100644 --- a/DrissionPage/_functions/settings.py +++ b/DrissionPage/_functions/settings.py @@ -15,7 +15,12 @@ class Settings(object): singleton_tab_obj = True cdp_timeout = 30 auto_handle_alert = None - locate_suffixes_list = str(Path(__file__).parent.absolute() / 'suffixes.dat').replace('\\', '/') + _suffixes_list = str(Path(__file__).parent.absolute() / 'suffixes.dat').replace('\\', '/') - def set_suffixes_list_path(self, path): - Settings.locate_suffixes_list = str(Path(path).absolute()) + @property + def suffixes_list_path(self): + return Settings._suffixes_list + + @suffixes_list_path.setter + def suffixes_list_path(self, path): + Settings._suffixes_list = str(Path(path).absolute()).replace('\\', '/') diff --git a/DrissionPage/_functions/settings.pyi b/DrissionPage/_functions/settings.pyi index 63eee47..5e79bd9 100644 --- a/DrissionPage/_functions/settings.pyi +++ b/DrissionPage/_functions/settings.pyi @@ -16,11 +16,9 @@ class Settings(object): singleton_tab_obj: bool = ... cdp_timeout: float = ... auto_handle_alert: Optional[bool] = ... - locate_suffixes_list: str = ... + _suffixes_list: str = ... - def set_suffixes_list_path(self, path: Union[str, Path]) -> None: - """设置用于识别域名后缀的文件路径 - :param path: 文件路径 - :return: None - """ + @property + def suffixes_list_path(self) -> str: + """设置用于识别域名后缀的文件路径""" ... diff --git a/DrissionPage/_pages/session_page.py b/DrissionPage/_pages/session_page.py index c1a787d..aed5fb4 100644 --- a/DrissionPage/_pages/session_page.py +++ b/DrissionPage/_pages/session_page.py @@ -158,7 +158,7 @@ class SessionPage(BasePage): if self.url: ex_url = TLDExtract( suffix_list_urls=["https://publicsuffix.org/list/public_suffix_list.dat", - f"file:///{Settings.locate_suffixes_list}"]).extract_str(self._session_url) + f"file:///{Settings.suffixes_list_path}"]).extract_str(self._session_url) domain = f'{ex_url.domain}.{ex_url.suffix}' if ex_url.suffix else ex_url.domain cookies = tuple(c for c in self.session.cookies if domain in c.domain or c.domain == '') else: diff --git a/DrissionPage/_units/setter.py b/DrissionPage/_units/setter.py index f3243af..fe271c8 100644 --- a/DrissionPage/_units/setter.py +++ b/DrissionPage/_units/setter.py @@ -271,6 +271,7 @@ class ChromiumPageSetter(TabSetter): self._owner._DownloadKit.set.save_path(path) def download_file_name(self, name=None, suffix=None): + super().download_file_name(name=name, suffix=suffix) self._owner.browser.set.download_file_name(name, suffix)