_common改名为_functions

This commit is contained in:
g1879 2023-12-08 23:31:25 +08:00
parent 30df1c8eb8
commit 1a5ec884f1
35 changed files with 42 additions and 39 deletions

View File

@ -13,4 +13,4 @@ from ._configs.chromium_options import ChromiumOptions
from ._configs.session_options import SessionOptions from ._configs.session_options import SessionOptions
__all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__'] __all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__']
__version__ = '4.0.0b17' __version__ = '4.0.0b18'

View File

@ -8,9 +8,9 @@ from re import sub
from DownloadKit import DownloadKit from DownloadKit import DownloadKit
from .._commons.settings import Settings from .._functions.settings import Settings
from .._commons.locator import get_loc from .._functions.locator import get_loc
from .._commons.web import format_html from .._functions.web import format_html
from .._elements.none_element import NoneElement from .._elements.none_element import NoneElement
from ..errors import ElementNotFoundError from ..errors import ElementNotFoundError

View File

@ -6,7 +6,7 @@
from time import sleep, perf_counter from time import sleep, perf_counter
from .chromium_driver import BrowserDriver, ChromiumDriver from .chromium_driver import BrowserDriver, ChromiumDriver
from .._commons.tools import stop_process_on_port, raise_error from .._functions.tools import stop_process_on_port, raise_error
from .._units.downloader import DownloadManager from .._units.downloader import DownloadManager
__ERROR__ = 'error' __ERROR__ = 'error'

View File

@ -10,7 +10,7 @@ from tempfile import gettempdir, TemporaryDirectory
from threading import Lock from threading import Lock
from .options_manage import OptionsManager from .options_manage import OptionsManager
from .._commons.tools import port_is_using, clean_folder from .._functions.tools import port_is_using, clean_folder
class ChromiumOptions(object): class ChromiumOptions(object):

View File

@ -9,7 +9,7 @@ from requests import Session
from requests.structures import CaseInsensitiveDict from requests.structures import CaseInsensitiveDict
from .options_manage import OptionsManager from .options_manage import OptionsManager
from .._commons.web import cookies_to_tuple, set_session_cookies from .._functions.web import cookies_to_tuple, set_session_cookies
class SessionOptions(object): class SessionOptions(object):

View File

@ -11,11 +11,11 @@ from time import perf_counter, sleep
from .none_element import NoneElement from .none_element import NoneElement
from .session_element import make_session_ele from .session_element import make_session_ele
from .._base.base import DrissionElement, BaseElement from .._base.base import DrissionElement, BaseElement
from .._commons.keys import input_text_or_keys from .._functions.keys import input_text_or_keys
from .._commons.locator import get_loc from .._functions.locator import get_loc
from .._commons.settings import Settings from .._functions.settings import Settings
from .._commons.tools import get_usable_path from .._functions.tools import get_usable_path
from .._commons.web import make_absolute_link, get_ele_txt, format_html, is_js_func, offset_scroll from .._functions.web import make_absolute_link, get_ele_txt, format_html, is_js_func, offset_scroll
from .._units.clicker import Clicker from .._units.clicker import Clicker
from .._units.rect import ElementRect from .._units.rect import ElementRect
from .._units.scroller import ElementScroller from .._units.scroller import ElementScroller

View File

@ -11,8 +11,8 @@ from lxml.html import HtmlElement, fromstring
from .none_element import NoneElement from .none_element import NoneElement
from .._base.base import DrissionElement, BasePage, BaseElement from .._base.base import DrissionElement, BasePage, BaseElement
from .._commons.locator import get_loc from .._functions.locator import get_loc
from .._commons.web import get_ele_txt, make_absolute_link from .._functions.web import get_ele_txt, make_absolute_link
class SessionElement(DrissionElement): class SessionElement(DrissionElement):

View File

@ -5,7 +5,7 @@
""" """
from click import command, option from click import command, option
from .._commons.tools import configs_to_here as ch from .._functions.tools import configs_to_here as ch
from .._configs.chromium_options import ChromiumOptions from .._configs.chromium_options import ChromiumOptions
from .._pages.chromium_page import ChromiumPage from .._pages.chromium_page import ChromiumPage

View File

@ -11,10 +11,10 @@ from time import perf_counter, sleep
from urllib.parse import quote from urllib.parse import quote
from .._base.base import BasePage from .._base.base import BasePage
from .._commons.locator import get_loc, is_loc from .._functions.locator import get_loc, is_loc
from .._commons.settings import Settings from .._functions.settings import Settings
from .._commons.tools import get_usable_path, raise_error from .._functions.tools import get_usable_path, raise_error
from .._commons.web import location_in_viewport from .._functions.web import location_in_viewport
from .._elements.chromium_element import ChromiumElement, run_js, make_chromium_ele from .._elements.chromium_element import ChromiumElement, run_js, make_chromium_ele
from .._elements.none_element import NoneElement from .._elements.none_element import NoneElement
from .._elements.session_element import make_session_ele from .._elements.session_element import make_session_ele

View File

@ -9,7 +9,7 @@ from time import sleep, perf_counter
from requests import get from requests import get
from .._base.browser import Browser from .._base.browser import Browser
from .._commons.browser import connect_browser from .._functions.browser import connect_browser
from .._configs.chromium_options import ChromiumOptions from .._configs.chromium_options import ChromiumOptions
from .._pages.chromium_base import ChromiumBase, Timeout from .._pages.chromium_base import ChromiumBase, Timeout
from .._pages.chromium_tab import ChromiumTab from .._pages.chromium_tab import ChromiumTab

View File

@ -6,7 +6,7 @@
from copy import copy from copy import copy
from .._base.base import BasePage from .._base.base import BasePage
from .._commons.web import set_session_cookies, set_browser_cookies from .._functions.web import set_session_cookies, set_browser_cookies
from .._configs.session_options import SessionOptions from .._configs.session_options import SessionOptions
from .._pages.chromium_base import ChromiumBase from .._pages.chromium_base import ChromiumBase
from .._pages.session_page import SessionPage from .._pages.session_page import SessionPage

View File

@ -13,9 +13,9 @@ from requests.structures import CaseInsensitiveDict
from tldextract import extract from tldextract import extract
from .._base.base import BasePage from .._base.base import BasePage
from .._commons.web import cookie_to_dict
from .._configs.session_options import SessionOptions from .._configs.session_options import SessionOptions
from .._elements.session_element import SessionElement, make_session_ele from .._elements.session_element import SessionElement, make_session_ele
from .._functions.web import cookie_to_dict
from .._units.setter import SessionPageSetter from .._units.setter import SessionPageSetter
@ -139,6 +139,8 @@ class SessionPage(BasePage):
:param kwargs: 连接参数 :param kwargs: 连接参数
:return: url是否可用 :return: url是否可用
""" """
if isinstance(url, Path):
url = str(url.absolute())
if not url.lower().startswith('http'): if not url.lower().startswith('http'):
if url.startswith('file:///'): if url.startswith('file:///'):
url = url[8:] url = url[8:]

View File

@ -3,6 +3,7 @@
@Author : g1879 @Author : g1879
@Contact : g1879@qq.com @Contact : g1879@qq.com
""" """
from pathlib import Path
from typing import Any, Union, Tuple, List, Optional from typing import Any, Union, Tuple, List, Optional
from requests import Session, Response from requests import Session, Response
@ -66,7 +67,7 @@ class SessionPage(BasePage):
def download_path(self) -> str: ... def download_path(self) -> str: ...
def get(self, def get(self,
url: str, url: Union[Path, str],
show_errmsg: bool | None = False, show_errmsg: bool | None = False,
retry: int | None = None, retry: int | None = None,
interval: float | None = None, interval: float | None = None,

View File

@ -7,8 +7,8 @@ from .chromium_page import ChromiumPage
from .chromium_tab import WebPageTab from .chromium_tab import WebPageTab
from .session_page import SessionPage from .session_page import SessionPage
from .._base.base import BasePage from .._base.base import BasePage
from .._commons.web import set_session_cookies, set_browser_cookies
from .._configs.chromium_options import ChromiumOptions from .._configs.chromium_options import ChromiumOptions
from .._functions.web import set_session_cookies, set_browser_cookies
from .._units.setter import WebPageSetter from .._units.setter import WebPageSetter

View File

@ -5,8 +5,8 @@
""" """
from time import sleep, perf_counter from time import sleep, perf_counter
from .._commons.keys import modifierBit, keyDescriptionForString, input_text_or_keys from .._functions.keys import modifierBit, keyDescriptionForString, input_text_or_keys
from .._commons.web import location_in_viewport from .._functions.web import location_in_viewport
class Actions: class Actions:

View File

@ -5,8 +5,8 @@
""" """
from time import perf_counter, sleep from time import perf_counter, sleep
from .._commons.settings import Settings from .._functions.settings import Settings
from .._commons.web import offset_scroll from .._functions.web import offset_scroll
from ..errors import CanNotClickError, CDPError, NoRectError from ..errors import CanNotClickError, CDPError, NoRectError

View File

@ -8,7 +8,7 @@ from pathlib import Path
from shutil import move from shutil import move
from time import sleep, perf_counter from time import sleep, perf_counter
from .._commons.tools import get_usable_path from .._functions.tools import get_usable_path
class DownloadManager(object): class DownloadManager(object):

View File

@ -9,7 +9,7 @@ from pathlib import Path
from threading import Thread from threading import Thread
from time import sleep, time from time import sleep, time
from .._commons.tools import clean_folder from .._functions.tools import clean_folder
class Screencast(object): class Screencast(object):

View File

@ -7,8 +7,8 @@ from pathlib import Path
from requests.structures import CaseInsensitiveDict from requests.structures import CaseInsensitiveDict
from .._commons.tools import show_or_hide_browser from .._functions.tools import show_or_hide_browser
from .._commons.web import set_browser_cookies, set_session_cookies from .._functions.web import set_browser_cookies, set_session_cookies
class BasePageSetter(object): class BasePageSetter(object):

View File

@ -3,7 +3,7 @@
@Author : g1879 @Author : g1879
@Contact : g1879@qq.com @Contact : g1879@qq.com
""" """
from .._commons.web import location_in_viewport from .._functions.web import location_in_viewport
from ..errors import CDPError, NoRectError, PageClosedError, ElementLostError from ..errors import CDPError, NoRectError, PageClosedError, ElementLostError

View File

@ -1,7 +1,7 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
from time import sleep, perf_counter from time import sleep, perf_counter
from .._commons.settings import Settings from .._functions.settings import Settings
from ..errors import WaitTimeoutError, NoRectError from ..errors import WaitTimeoutError, NoRectError

View File

@ -3,11 +3,11 @@
@Author : g1879 @Author : g1879
@Contact : g1879@qq.com @Contact : g1879@qq.com
""" """
from ._commons.by import By
from ._commons.keys import Keys
from ._commons.settings import Settings
from ._commons.tools import wait_until, configs_to_here
from ._elements.session_element import make_session_ele from ._elements.session_element import make_session_ele
from ._functions.by import By
from ._functions.keys import Keys
from ._functions.settings import Settings
from ._functions.tools import wait_until, configs_to_here
from ._units.actions import Actions from ._units.actions import Actions
__all__ = ['make_session_ele', 'Actions', 'Keys', 'By', 'Settings', 'wait_until', 'configs_to_here'] __all__ = ['make_session_ele', 'Actions', 'Keys', 'By', 'Settings', 'wait_until', 'configs_to_here']

View File

@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
setup( setup(
name="DrissionPage", name="DrissionPage",
version="4.0.0b17", version="4.0.0b18",
author="g1879", author="g1879",
author_email="g1879@qq.com", author_email="g1879@qq.com",
description="Python based web automation tool. It can control the browser and send and receive data packets.", description="Python based web automation tool. It can control the browser and send and receive data packets.",