PEP 8 compliance.
This commit is contained in:
parent
66fd1bfe11
commit
84b8c1b626
1 changed files with 42 additions and 26 deletions
36
dcc/ss.py
36
dcc/ss.py
|
@ -5,6 +5,7 @@ import sys
|
||||||
import wand.display
|
import wand.display
|
||||||
import wand.image
|
import wand.image
|
||||||
|
|
||||||
|
|
||||||
class SS(dcc.doom_base.WadMap):
|
class SS(dcc.doom_base.WadMap):
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super().get_parser(prog_name)
|
parser = super().get_parser(prog_name)
|
||||||
|
@ -13,24 +14,39 @@ class SS(dcc.doom_base.WadMap):
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def try_screenshot():
|
while not self._try_screenshot(parsed_args.gravity, parsed_args.yolo):
|
||||||
with wand.image.Image(width=dcc.config.THUMB_WIDTH, height=dcc.config.THUMB_HEIGHT, pseudo="x:") as img:
|
pass
|
||||||
|
|
||||||
|
def _try_screenshot(self, gravity, yolo):
|
||||||
|
with wand.image.Image(
|
||||||
|
width=dcc.config.THUMB_WIDTH,
|
||||||
|
height=dcc.config.THUMB_HEIGHT,
|
||||||
|
pseudo="x:"
|
||||||
|
) as img:
|
||||||
img.reset_coords()
|
img.reset_coords()
|
||||||
if img.size[0] < dcc.config.THUMB_WIDTH or img.size[1] < dcc.config.THUMB_HEIGHT:
|
if (
|
||||||
if not messagebox.askretrycancel(title="DCC", message="Image too small. Try again?"):
|
img.size[0] < dcc.config.THUMB_WIDTH
|
||||||
|
or img.size[1] < dcc.config.THUMB_HEIGHT
|
||||||
|
):
|
||||||
|
if not messagebox.askretrycancel(
|
||||||
|
title="DCC", message="Image too small. Try again?"
|
||||||
|
):
|
||||||
sys.exit("Gave up trying to select an image.")
|
sys.exit("Gave up trying to select an image.")
|
||||||
return False
|
return False
|
||||||
img.crop(width=dcc.config.THUMB_WIDTH,height=dcc.config.THUMB_HEIGHT,gravity=parsed_args.gravity)
|
img.crop(
|
||||||
|
width=dcc.config.THUMB_WIDTH,
|
||||||
|
height=dcc.config.THUMB_HEIGHT,
|
||||||
|
gravity=gravity
|
||||||
|
)
|
||||||
img.reset_coords()
|
img.reset_coords()
|
||||||
if not parsed_args.yolo:
|
if not yolo:
|
||||||
wand.display.display(img)
|
wand.display.display(img)
|
||||||
accepted = messagebox.askyesnocancel(title="DCC", message="Is this image acceptable?")
|
accepted = messagebox.askyesnocancel(
|
||||||
|
title="DCC", message="Is this image acceptable?"
|
||||||
|
)
|
||||||
if accepted is None:
|
if accepted is None:
|
||||||
sys.exit("Gave up on image verification")
|
sys.exit("Gave up on image verification")
|
||||||
if not accepted:
|
if not accepted:
|
||||||
return False
|
return False
|
||||||
img.save(filename=self.base_thumb_path())
|
img.save(filename=self.base_thumb_path())
|
||||||
return True
|
return True
|
||||||
|
|
||||||
while not try_screenshot():
|
|
||||||
pass
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue