Skip to content

Commit

Permalink
feat: add python type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Dec 20, 2023
1 parent e9d1575 commit 4a20e28
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
19 changes: 11 additions & 8 deletions bindings/python/rookiepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from sys import platform
from typing import List, Any
from typing import List
import http.cookiejar
from .rookiepy import (
firefox,
firefox,
firefox_based,
brave,
edge,
chrome,
Expand Down Expand Up @@ -38,14 +39,18 @@

# Windows
if platform == "win32":
from .rookiepy import internet_explorer
__all__.append("internet_explorer")
__all__.append("octo_browser") # only windows supported for now
from .rookiepy import internet_explorer, octo_browser
__all__.extend([
"internet_explorer",
"octo_browser"
])

# MacOS
if platform == "darwin":
from .rookiepy import safari
__all__.append("safari")
__all__.extend([
"safari"
])


def create_cookie(host, path, secure, expires, name, value, http_only):
Expand All @@ -55,8 +60,6 @@ def create_cookie(host, path, secure, expires, name, value, http_only):
True, secure, expires, False, None, None,
{'HTTPOnly': ''} if http_only else {})



def to_cookiejar(cookies: List[dict]):
cj = http.cookiejar.CookieJar()

Expand Down
Empty file.
31 changes: 31 additions & 0 deletions bindings/python/rookiepy/rookiepy.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import List
from sys import platform
from http.cookiejar import CookieJar, Cookie


def firefox(domains: List[str] = None) -> List[dict]: ...
def firefox_based(key_path: str, db_path: str, domains: List[str] = None) -> List[dict]: ...
def brave(domains: List[str] = None) -> List[dict]: ...
def edge(domains: List[str] = None) -> List[dict]: ...
def chrome(domains: List[str] = None) -> List[dict]: ...
def chromium_based(db_path: str, domains: List[str] = None) -> List[dict]: ...
def chromium(domains: List[str] = None) -> List[dict]: ...
def opera(domains: List[str] = None) -> List[dict]: ...
def vivaldi(domains: List[str] = None) -> List[dict]: ...
def opera_gx(domains: List[str] = None) -> List[dict]: ...
def libre_wolf(domains: List[str] = None) -> List[dict]: ...
def load(domains: List[str] = None) -> List[dict]: ...
def any_browser(domains: List[str] = None) -> List[dict]: ...

# Windows
if platform == "win32":
def internet_explorer(domains: List[str] = None) -> List[dict]: ...
def octo_browser(domains: List[str] = None) -> List[dict]: ...

# MacOS
if platform == "darwin":
def safari(domains: List[str] = None) -> List[dict]: ...


def create_cookie(host: str, path: str, secure: bool, expires: int, name: str, value: str, http_only: bool) -> Cookie: ...
def to_cookiejar(cookies: List[dict]) -> CookieJar: ...

0 comments on commit 4a20e28

Please sign in to comment.