Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Simplify conditional expressions

Co-authored-by: Andrew Murray <[email protected]>
  • Loading branch information
TheNooB2706 and radarhere authored Aug 11, 2023
1 parent 164ea2d commit a8b3fea
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ def grabclipboard():
else: # Session type check failed
sessiontype = None

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

0 comments on commit a8b3fea

Please sign in to comment.