Skip to content

Commit

Permalink
Merge pull request #2 from radarhere/grabclipboard
Browse files Browse the repository at this point in the history
Simplified code
  • Loading branch information
nik012003 committed Jan 27, 2024
2 parents 6998f34 + d3205fa commit 9392f24
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def grabclipboard():

p = subprocess.run(args, capture_output=True)
if p.returncode != 0:
allowed_errors = [
err = p.stderr
for silent_error in [

Check warning on line 162 in src/PIL/ImageGrab.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/ImageGrab.py#L160-L162

Added lines #L160 - L162 were not covered by tests
# wl-paste, when the clipboard is empty
b"Nothing is copied",
# wl-paste/debian xclip, when an image isn't available
Expand All @@ -167,10 +168,9 @@ def grabclipboard():
b"cannot convert",
# xclip, when the clipboard isn't initialized
b"There is no owner",
]
err = p.stderr
if any(e in err for e in allowed_errors):
return None
]:
if err in silent_error:
return None
msg = f"{args[0]} error"
if err:
msg += f": {err.strip().decode()}"

Check warning on line 176 in src/PIL/ImageGrab.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/ImageGrab.py#L172-L176

Added lines #L172 - L176 were not covered by tests
Expand Down

0 comments on commit 9392f24

Please sign in to comment.