Skip to content

Commit fd783bc

Browse files
stored system().lower() in a variable
1 parent 74873ca commit fd783bc

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

pywhatkit/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pywhatkit.ascii_art import image_to_ascii_art
1212
from pywhatkit.handwriting import text_to_handwriting
1313
from pywhatkit.mail import send_hmail, send_mail
14-
from pywhatkit.misc import info, playonyt, search, show_history, web_screenshot
14+
from pywhatkit.misc import info, playonyt, search, show_history, take_screenshot
1515
from pywhatkit.sc import cancel_shutdown, shutdown
1616
from pywhatkit.whats import (
1717
open_web,
@@ -22,8 +22,9 @@
2222
sendwhats_image,
2323
)
2424

25-
if system().lower() in ("darwin", "windows"):
25+
_system = system().lower()
26+
if _system in ("darwin", "windows"):
2627
from pywhatkit.misc import take_screenshot
2728

28-
if system().lower() == "windows":
29+
if _system == "windows":
2930
from pywhatkit.remotekit import start_server

pywhatkit/core/core.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ def close_tab(wait_time: int = 2) -> None:
2323
"""Closes the Currently Opened Browser Tab"""
2424

2525
time.sleep(wait_time)
26-
system_ = system().lower()
27-
if system_ in ("windows", "linux"):
26+
_system = system().lower()
27+
if _system in ("windows", "linux"):
2828
hotkey("ctrl", "w")
29-
elif system_ == "darwin":
29+
elif _system == "darwin":
3030
hotkey("command", "w")
3131
else:
32-
raise Warning(f"{system_} not supported!")
32+
raise Warning(f"{_system} not supported!")
3333
press("enter")
3434

3535

@@ -89,8 +89,8 @@ def send_message(message: str, receiver: str, wait_time: int) -> None:
8989
def copy_image(path: str) -> None:
9090
"""Copy the Image to Clipboard based on the Platform"""
9191

92-
system_ = system().lower()
93-
if system_ == "linux":
92+
_system = system().lower()
93+
if _system == "linux":
9494
if pathlib.Path(path).suffix in (".PNG", ".png"):
9595
os.system(f"copyq copy image/png - < {path}")
9696
elif pathlib.Path(path).suffix in (".jpg", ".JPG", ".jpeg", ".JPEG"):
@@ -99,7 +99,7 @@ def copy_image(path: str) -> None:
9999
raise Exception(
100100
f"File Format {pathlib.Path(path).suffix} is not Supported!"
101101
)
102-
elif system_ == "windows":
102+
elif _system == "windows":
103103
from io import BytesIO
104104

105105
import win32clipboard # pip install pywin32
@@ -114,7 +114,7 @@ def copy_image(path: str) -> None:
114114
win32clipboard.EmptyClipboard()
115115
win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
116116
win32clipboard.CloseClipboard()
117-
elif system_ == "darwin":
117+
elif _system == "darwin":
118118
if pathlib.Path(path).suffix in (".jpg", ".jpeg", ".JPG", ".JPEG"):
119119
os.system(
120120
f"osascript -e 'set the clipboard to (read (POSIX file \"{path}\") as JPEG picture)'"
@@ -124,7 +124,7 @@ def copy_image(path: str) -> None:
124124
f"File Format {pathlib.Path(path).suffix} is not Supported!"
125125
)
126126
else:
127-
raise Exception(f"Unsupported System: {system_}")
127+
raise Exception(f"Unsupported System: {_system}")
128128

129129

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

0 commit comments

Comments
 (0)