Skip to content

Commit 74873ca

Browse files
commit
1 parent 986a6ca commit 74873ca

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

pywhatkit/core/core.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66
from webbrowser import open
77

88
import requests
9-
from pyautogui import (
10-
click,
11-
hotkey,
12-
locateOnScreen,
13-
moveTo,
14-
press,
15-
size,
16-
typewrite,
17-
)
9+
from pyautogui import click, hotkey, locateOnScreen, moveTo, press, size, typewrite
1810

1911
from pywhatkit.core.exceptions import InternetException
2012

@@ -31,12 +23,13 @@ def close_tab(wait_time: int = 2) -> None:
3123
"""Closes the Currently Opened Browser Tab"""
3224

3325
time.sleep(wait_time)
34-
if system().lower() in ("windows", "linux"):
26+
system_ = system().lower()
27+
if system_ in ("windows", "linux"):
3528
hotkey("ctrl", "w")
36-
elif system().lower() == "darwin":
29+
elif system_ == "darwin":
3730
hotkey("command", "w")
3831
else:
39-
raise Warning(f"{system().lower()} not supported!")
32+
raise Warning(f"{system_} not supported!")
4033
press("enter")
4134

4235

@@ -96,7 +89,8 @@ def send_message(message: str, receiver: str, wait_time: int) -> None:
9689
def copy_image(path: str) -> None:
9790
"""Copy the Image to Clipboard based on the Platform"""
9891

99-
if system().lower() == "linux":
92+
system_ = system().lower()
93+
if system_ == "linux":
10094
if pathlib.Path(path).suffix in (".PNG", ".png"):
10195
os.system(f"copyq copy image/png - < {path}")
10296
elif pathlib.Path(path).suffix in (".jpg", ".JPG", ".jpeg", ".JPEG"):
@@ -105,7 +99,7 @@ def copy_image(path: str) -> None:
10599
raise Exception(
106100
f"File Format {pathlib.Path(path).suffix} is not Supported!"
107101
)
108-
elif system().lower() == "windows":
102+
elif system_ == "windows":
109103
from io import BytesIO
110104

111105
import win32clipboard # pip install pywin32
@@ -120,7 +114,7 @@ def copy_image(path: str) -> None:
120114
win32clipboard.EmptyClipboard()
121115
win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
122116
win32clipboard.CloseClipboard()
123-
elif system().lower() == "darwin":
117+
elif system_ == "darwin":
124118
if pathlib.Path(path).suffix in (".jpg", ".jpeg", ".JPG", ".JPEG"):
125119
os.system(
126120
f"osascript -e 'set the clipboard to (read (POSIX file \"{path}\") as JPEG picture)'"
@@ -130,7 +124,7 @@ def copy_image(path: str) -> None:
130124
f"File Format {pathlib.Path(path).suffix} is not Supported!"
131125
)
132126
else:
133-
raise Exception(f"Unsupported System: {system().lower()}")
127+
raise Exception(f"Unsupported System: {system_}")
134128

135129

136130
def send_image(path: str, caption: str, receiver: str, wait_time: int) -> None:

0 commit comments

Comments
 (0)