mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Merge pull request #3 from radarhere/fix-imagegrab-with-wl-paste
Formatting
This commit is contained in:
commit
1dffa86e20
|
@ -102,7 +102,7 @@ $ms = new-object System.IO.MemoryStream(, $bytes)
|
|||
@pytest.mark.skipif(
|
||||
(
|
||||
sys.platform != "linux"
|
||||
or not all(shutil.which(cmd) for cmd in ["wl-paste", "wl-copy"])
|
||||
or not all(shutil.which(cmd) for cmd in ("wl-paste", "wl-copy"))
|
||||
),
|
||||
reason="Linux with wl-clipboard only",
|
||||
)
|
||||
|
@ -111,5 +111,5 @@ $ms = new-object System.IO.MemoryStream(, $bytes)
|
|||
image_path = "Tests/images/hopper." + ext
|
||||
with open(image_path, "rb") as fp:
|
||||
subprocess.call(["wl-copy"], stdin=fp)
|
||||
im = ImageGrab.grabclipboard()
|
||||
assert_image_equal_tofile(im, image_path)
|
||||
im = ImageGrab.grabclipboard()
|
||||
assert_image_equal_tofile(im, image_path)
|
||||
|
|
|
@ -142,17 +142,16 @@ def grabclipboard():
|
|||
return None
|
||||
else:
|
||||
if shutil.which("wl-paste"):
|
||||
args = ["wl-paste"]
|
||||
output = subprocess.check_output(["wl-paste", "-l"]).decode()
|
||||
clipboard_mimetypes = output.splitlines()
|
||||
mimetypes = output.splitlines()
|
||||
if "image/png" in mimetypes:
|
||||
mimetype = "image/png"
|
||||
elif mimetypes:
|
||||
mimetype = mimetypes[0]
|
||||
else:
|
||||
mimetype = None
|
||||
|
||||
def find_mimetype():
|
||||
if "image/png" in clipboard_mimetypes:
|
||||
return "image/png"
|
||||
if clipboard_mimetypes:
|
||||
return clipboard_mimetypes[0]
|
||||
|
||||
mimetype = find_mimetype()
|
||||
args = ["wl-paste"]
|
||||
if mimetype:
|
||||
args.extend(["-t", mimetype])
|
||||
elif shutil.which("xclip"):
|
||||
|
|
Loading…
Reference in New Issue
Block a user