Apply suggestions from code review

Simplify conditional expressions

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
TheNooB 2023-08-11 21:01:05 +08:00 committed by GitHub
parent 164ea2df6f
commit a8b3feac86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,9 +164,7 @@ def grabclipboard():
else: # Session type check failed else: # Session type check failed
sessiontype = None sessiontype = None
if shutil.which("wl-paste") and ( if shutil.which("wl-paste") and sessiontype in ["wayland", None]:
(sessiontype == "wayland") or (sessiontype is None)
):
output = subprocess.check_output(["wl-paste", "-l"]).decode() output = subprocess.check_output(["wl-paste", "-l"]).decode()
mimetypes = output.splitlines() mimetypes = output.splitlines()
if "image/png" in mimetypes: if "image/png" in mimetypes:
@ -179,9 +177,7 @@ def grabclipboard():
args = ["wl-paste"] args = ["wl-paste"]
if mimetype: if mimetype:
args.extend(["-t", mimetype]) args.extend(["-t", mimetype])
elif shutil.which("xclip") and ( elif shutil.which("xclip") and sessiontype in ["x11", None]:
(sessiontype == "x11") or (sessiontype is None)
):
args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"] args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"]
else: else:
msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux" msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux"