Switched to more descriptive variable names

This commit is contained in:
Andrew Murray 2016-04-19 17:39:59 +10:00
parent 935ac523bf
commit af92d24837

View File

@ -31,12 +31,12 @@ elif sys.platform == "darwin":
def grab(bbox=None):
if sys.platform == "darwin":
f, file = tempfile.mkstemp('.png')
os.close(f)
subprocess.call(['screencapture', '-x', file])
im = Image.open(file)
fh, filepath = tempfile.mkstemp('.png')
os.close(fh)
subprocess.call(['screencapture', '-x', filepath])
im = Image.open(filepath)
im.load()
os.unlink(file)
os.unlink(filepath)
else:
size, data = grabber()
im = Image.frombytes(
@ -51,10 +51,10 @@ def grab(bbox=None):
def grabclipboard():
if sys.platform == "darwin":
f, file = tempfile.mkstemp('.jpg')
os.close(f)
fh, filepath = tempfile.mkstemp('.jpg')
os.close(fh)
commands = [
"set theFile to (open for access POSIX file \""+file+"\" with write permission)",
"set theFile to (open for access POSIX file \""+filepath+"\" with write permission)",
"try",
"write (the clipboard as JPEG picture) to theFile",
"end try",
@ -66,10 +66,10 @@ def grabclipboard():
subprocess.call(script)
im = None
if os.stat(file).st_size != 0:
im = Image.open(file)
if os.stat(filepath).st_size != 0:
im = Image.open(filepath)
im.load()
os.unlink(file)
os.unlink(filepath)
return im
else:
debug = 0 # temporary interface