From c4ef1e2b9590f92dd5b3759e93add7fadf77a464 Mon Sep 17 00:00:00 2001 From: g1879 Date: Thu, 19 Nov 2020 23:58:36 +0800 Subject: [PATCH] =?UTF-8?q?OptionsManager=E5=A2=9E=E5=8A=A0=E4=B8=89?= =?UTF-8?q?=E4=B8=AA=E5=B1=9E=E6=80=A7=E5=8F=8A=5F=5Ftext=5F=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/config.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/DrissionPage/config.py b/DrissionPage/config.py index 6479d63..ad25efc 100644 --- a/DrissionPage/config.py +++ b/DrissionPage/config.py @@ -30,6 +30,27 @@ class OptionsManager(object): self.set_item('paths', 'global_tmp_path', global_tmp_path) self.save() + def __text__(self) -> str: + """打印ini文件内容""" + return (f"paths:\n" + f"{self.get_option('paths')}\n\n" + "chrome options:\n" + f"{self.get_option('chrome_options')}\n\n" + "session options:\n" + f"{self.get_option('session_options')}") + + @property + def paths(self) -> dict: + return self.get_option('paths') + + @property + def chrome_options(self) -> dict: + return self.get_option('chrome_options') + + @property + def session_options(self) -> dict: + return self.get_option('session_options') + def get_value(self, section: str, item: str) -> Any: """获取配置的值 \n :param section: 段名