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