Skip to content

Commit

Permalink
Merge pull request #6 from Kaliiiiiiiiii-Vinyzu/main
Browse files Browse the repository at this point in the history
Update v1.1
[skip ci]
  • Loading branch information
kaliiiiiiiiii authored Apr 27, 2024
2 parents 1fed15a + b633d9c commit 0c19da2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 166 deletions.
5 changes: 3 additions & 2 deletions cdp_patches/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import platform
import warnings

VERSION = 1.0
VERSION = "1.1"

system_name = platform.system()
if system_name == "Windows":
is_windows = True
elif system_name == "Linux":
is_windows = False
else:
raise SystemError("Unknown system (You´re probably using MacOS, which is currently not supported).")
warnings.warn("Unknown system (You´re probably using MacOS, which is currently not supported).", RuntimeWarning)

__all__ = ["VERSION", "is_windows"]
5 changes: 4 additions & 1 deletion cdp_patches/input/async_input.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

import asyncio
import platform
import random
import re
import sys
import time
import warnings
from typing import Any, Generator, Literal, Optional, Union

if sys.version_info.minor >= 10:
Expand Down Expand Up @@ -51,6 +51,9 @@ class AsyncInput:
def __init__(
self, pid: Optional[int] = None, browser: Optional[async_browsers] = None, scale_factor: Optional[float] = 1.0, emulate_behaviour: Optional[bool] = True, window_timeout: Optional[float] = 30.0
) -> None:
if platform.system() not in ('Windows', 'Linux'):
raise SystemError("Unknown system (You´re probably using MacOS, which is currently not supported).")

self.pid = pid
self.browser = browser
self.window_timeout = window_timeout or self.window_timeout
Expand Down
5 changes: 4 additions & 1 deletion cdp_patches/input/sync_input.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import platform
import random
import re
import sys
import threading
import time
import warnings
from typing import Literal, Optional, Union

if sys.version_info.minor >= 10:
Expand Down Expand Up @@ -50,6 +50,9 @@ class SyncInput:
def __init__(
self, pid: Optional[int] = None, browser: Optional[sync_browsers] = None, scale_factor: Optional[float] = 1.0, emulate_behaviour: Optional[bool] = True, window_timeout: Optional[float] = 30.0
) -> None:
if platform.system() not in ('Windows', 'Linux'):
raise SystemError("Unknown system (You´re probably using MacOS, which is currently not supported).")

self._scale_factor = scale_factor or self._scale_factor
self.window_timeout = window_timeout or self.window_timeout
self.emulate_behaviour = emulate_behaviour or self.emulate_behaviour
Expand Down
8 changes: 7 additions & 1 deletion docs/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

0.1 (2024-03-23)
1.1 (2024-04-24)
------------------
- Official Support Scrolling. [Vinyzu]
- Change Exception to Warning when importing CDP-Patches on MacOS. [Vinyzu]
- Fix Documentation. [Vinyzu]

1.0(2024-03-23)
------------------
- Initial Release. [Vinyzu]
6 changes: 4 additions & 2 deletions docs/gitbook/input/playwright-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ with sync_playwright() as playwright:

```python
import asyncio

from playwright.async_api import async_playwright, Locator
from cdp_patches.input import AsyncInput

Expand All @@ -45,8 +46,9 @@ async def get_locator_pos(locator: Locator):
bounding_box = await locator.bounding_box()
assert bounding_box

x, y, width, height = bounding_box.get("x"), bounding_box.get("y"), bounding_box.get("width"), bounding_box.get(
"height")

x, y, width, height = bounding_box.get("x"), bounding_box.get("y"), bounding_box.get("width"), bounding_box.get("height")

assert x and y and width and height

x, y = x + width // 2, y + height // 2
Expand Down
159 changes: 0 additions & 159 deletions docs/index.rst

This file was deleted.

0 comments on commit 0c19da2

Please sign in to comment.