mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
截图左上和右下参数可只接收其中一个;配置对象save()可生成不存在的路径
This commit is contained in:
parent
ec6a2d4494
commit
cbec20fc97
@ -532,9 +532,9 @@ class ChromiumOptions(object):
|
||||
path = path / 'config.ini' if path.is_dir() else path
|
||||
|
||||
if path.exists():
|
||||
om = OptionsManager(str(path))
|
||||
om = OptionsManager(path)
|
||||
else:
|
||||
om = OptionsManager(self.ini_path or str(Path(__file__).parent / 'configs.ini'))
|
||||
om = OptionsManager(self.ini_path or (Path(__file__).parent / 'configs.ini'))
|
||||
|
||||
# 设置chromium_options
|
||||
attrs = ('address', 'browser_path', 'arguments', 'extensions', 'user', 'load_mode',
|
||||
|
@ -29,6 +29,8 @@ class OptionsManager(object):
|
||||
self.ini_path = default_configs
|
||||
elif path == 'default':
|
||||
self.ini_path = default_configs
|
||||
elif isinstance(path, Path):
|
||||
self.ini_path = path
|
||||
else:
|
||||
self.ini_path = Path(path)
|
||||
|
||||
@ -147,6 +149,7 @@ class OptionsManager(object):
|
||||
path = Path(path).absolute()
|
||||
|
||||
path = path / 'config.ini' if path.is_dir() else path
|
||||
path.parent.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
path = str(path)
|
||||
self._conf.write(open(path, 'w', encoding='utf-8'))
|
||||
|
@ -7,7 +7,7 @@
|
||||
"""
|
||||
from configparser import RawConfigParser
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
|
||||
class OptionsManager(object):
|
||||
@ -15,7 +15,7 @@ class OptionsManager(object):
|
||||
file_exists: bool = ...
|
||||
_conf: RawConfigParser = ...
|
||||
|
||||
def __init__(self, path: str = None): ...
|
||||
def __init__(self, path: Union[Path, str] = None): ...
|
||||
|
||||
def __getattr__(self, item) -> dict: ...
|
||||
|
||||
|
@ -377,9 +377,9 @@ class SessionOptions(object):
|
||||
path = path / 'config.ini' if path.is_dir() else path
|
||||
|
||||
if path.exists():
|
||||
om = OptionsManager(str(path))
|
||||
om = OptionsManager(path)
|
||||
else:
|
||||
om = OptionsManager(self.ini_path or str(Path(__file__).parent / 'configs.ini'))
|
||||
om = OptionsManager(self.ini_path or (Path(__file__).parent / 'configs.ini'))
|
||||
|
||||
options = session_options_to_dict(self)
|
||||
|
||||
|
@ -1064,7 +1064,11 @@ class ChromiumBase(BasePage):
|
||||
vp = {'x': 0, 'y': 0, 'width': width, 'height': height, 'scale': 1}
|
||||
args = {'format': pic_type, 'captureBeyondViewport': True, 'clip': vp}
|
||||
else:
|
||||
if left_top and right_bottom:
|
||||
if left_top or right_bottom:
|
||||
if not left_top:
|
||||
left_top = (0, 0)
|
||||
if not right_bottom:
|
||||
right_bottom = self.rect.size
|
||||
x, y = left_top
|
||||
w = right_bottom[0] - x
|
||||
h = right_bottom[1] - y
|
||||
|
Loading…
x
Reference in New Issue
Block a user