From 80070e3a5ea3d44358393060dbb7b303e1798e15 Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 12:18:46 -0400 Subject: [PATCH 1/7] PEP 8 compliance. --- dcc/ls.py | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/dcc/ls.py b/dcc/ls.py index 9fb1a81..62fdb37 100644 --- a/dcc/ls.py +++ b/dcc/ls.py @@ -1,27 +1,39 @@ import dcc.config import os + class List(dcc.config.Base): - def get_parser(self, prog_name): - parser = super().get_parser(prog_name) - parser.add_argument("target") - parser.add_argument("--wad") - return parser + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + parser.add_argument("target") + parser.add_argument("--wad") + return parser - def take_action(self, parsed_args): - match parsed_args.target: - case "pwads": - self.list(x.name for x in os.scandir(self.pwads) if x.is_dir()) - case "iwads": - self.list(x.name for x in os.scandir(self.iwads) if x.is_file()) - case "demos": - self.list(x.name for x in os.scandir(self.demos.joinpath(parsed_args.wad)) if x.name.endswith(".lmp")) - case "videos": - self.list(x.name for x in os.scandir(self.fabricate.joinpath(parsed_args.wad)) if x.name.endswith(".mp4")) - case _: - raise Exception(f"unknown target {parsed_args.target}") + def take_action(self, parsed_args): + match parsed_args.target: + case "pwads": + self.list(x.name for x in os.scandir(self.pwads) if x.is_dir()) + case "iwads": + self.list( + x.name for x in os.scandir(self.iwads) + if x.is_file() + ) + case "demos": + self.list( + x.name for x in + os.scandir(self.demos.joinpath(parsed_args.wad)) + if x.name.endswith(".lmp") + ) + case "videos": + self.list( + x.name for x in + os.scandir(self.fabricate.joinpath(parsed_args.wad)) + if x.name.endswith(".mp4") + ) + case _: + raise Exception(f"unknown target {parsed_args.target}") - def list(self, gen): - # TODO: fancy text? - for i in sorted(gen): - print(i) + def list(self, gen): + # TODO: fancy text? + for i in sorted(gen): + print(i) From 69ce44522556c1062bfe2efcf0c60139897e8bb6 Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 12:20:12 -0400 Subject: [PATCH 2/7] PEP 8 compliance. --- dcc/main.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/dcc/main.py b/dcc/main.py index 877ec9d..09dfc41 100644 --- a/dcc/main.py +++ b/dcc/main.py @@ -3,27 +3,30 @@ import sys from cliff.app import App from cliff.commandmanager import CommandManager + class DCC(App): - def __init__(self): - super().__init__( - description="Doom Command Center", - version="0.0.1", - command_manager=CommandManager("dcc"), - deferred_help=True, - ) + def __init__(self): + super().__init__( + description="Doom Command Center", + version="0.0.1", + command_manager=CommandManager("dcc"), + deferred_help=True, + ) - def initialize_app(self, argv): - pass + def initialize_app(self, argv): + pass - def prepare_to_run_command(self, cmd): - pass + def prepare_to_run_command(self, cmd): + pass + + def clean_up(self, cmd, result, err): + pass - def clean_up(self, cmd, result, err): - pass def main(argv=sys.argv[1:]): - dcc = DCC() - return dcc.run(argv) + dcc = DCC() + return dcc.run(argv) + if __name__ == '__main__': - sys.exit(main()) + sys.exit(main()) From dace0de99b086a894b4c0947bdacb02668b23162 Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 12:23:32 -0400 Subject: [PATCH 3/7] PEP 8 compliance. --- dcc/pb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dcc/pb.py b/dcc/pb.py index db6e907..a1def16 100644 --- a/dcc/pb.py +++ b/dcc/pb.py @@ -2,6 +2,7 @@ import dcc.config import dcc.doom_base import subprocess + class PB(dcc.doom_base.WadMap): - def take_action(self, parsed_args): - subprocess.run(["ffplay", self.video_path()]) + def take_action(self, parsed_args): + subprocess.run(["ffplay", self.video_path()]) From 66fd1bfe1136dfa1187ac281a4ba8795085a6c4a Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 12:25:52 -0400 Subject: [PATCH 4/7] PEP 8 compliance. --- dcc/put.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/dcc/put.py b/dcc/put.py index 105d5b4..59e1dbc 100644 --- a/dcc/put.py +++ b/dcc/put.py @@ -2,16 +2,22 @@ import boto3 import dcc.config import dcc.doom_base -class Put(dcc.doom_base.WadMap): - def get_parser(self, prog_name): - parser = super().get_parser(prog_name) - return parser - # TODO: accept configuration for bucket name - def take_action(self, parsed_args): - s3_client = boto3.client('s3') - demo = self.demo_in_path() - bucket = self.target_bucket() - print("Uploading {} to bucket {}.".format(demo, bucket)) - s3_client.upload_file(demo, 'yrriban', bucket, - ExtraArgs={'ContentType': 'binary/octet-stream', 'ACL': 'public-read'}) +class Put(dcc.doom_base.WadMap): + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + return parser + + # TODO: accept configuration for bucket name + def take_action(self, parsed_args): + s3_client = boto3.client('s3') + demo = self.demo_in_path() + bucket = self.target_bucket() + print("Uploading {} to bucket {}.".format(demo, bucket)) + s3_client.upload_file( + demo, 'yrriban', bucket, + ExtraArgs={ + 'ContentType': 'binary/octet-stream', + 'ACL': 'public-read' + } + ) From 84b8c1b6261d94158ae1df222c373c69331f342e Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 12:31:37 -0400 Subject: [PATCH 5/7] PEP 8 compliance. --- dcc/ss.py | 68 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/dcc/ss.py b/dcc/ss.py index 2579a3b..6d5dc2e 100644 --- a/dcc/ss.py +++ b/dcc/ss.py @@ -5,32 +5,48 @@ import sys import wand.display import wand.image + class SS(dcc.doom_base.WadMap): - def get_parser(self, prog_name): - parser = super().get_parser(prog_name) - parser.add_argument("-g", "--gravity", default="center") - parser.add_argument("-y", "--yolo", action="store_true") - return parser + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + parser.add_argument("-g", "--gravity", default="center") + parser.add_argument("-y", "--yolo", action="store_true") + return parser - def take_action(self, parsed_args): - def try_screenshot(): - with wand.image.Image(width=dcc.config.THUMB_WIDTH, height=dcc.config.THUMB_HEIGHT, pseudo="x:") as img: - img.reset_coords() - if 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.") - return False - img.crop(width=dcc.config.THUMB_WIDTH,height=dcc.config.THUMB_HEIGHT,gravity=parsed_args.gravity) - img.reset_coords() - if not parsed_args.yolo: - wand.display.display(img) - accepted = messagebox.askyesnocancel(title="DCC", message="Is this image acceptable?") - if accepted is None: - sys.exit("Gave up on image verification") - if not accepted: - return False - img.save(filename=self.base_thumb_path()) - return True + def take_action(self, parsed_args): + while not self._try_screenshot(parsed_args.gravity, parsed_args.yolo): + pass - while not try_screenshot(): - 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() + if ( + 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.") + return False + img.crop( + width=dcc.config.THUMB_WIDTH, + height=dcc.config.THUMB_HEIGHT, + gravity=gravity + ) + img.reset_coords() + if not yolo: + wand.display.display(img) + accepted = messagebox.askyesnocancel( + title="DCC", message="Is this image acceptable?" + ) + if accepted is None: + sys.exit("Gave up on image verification") + if not accepted: + return False + img.save(filename=self.base_thumb_path()) + return True From 2076e7341d51ec925d743fa40f672958a36f3084 Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 13:31:32 -0400 Subject: [PATCH 6/7] PEP 8 compliance. --- dcc/text.py | 60 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/dcc/text.py b/dcc/text.py index cf11970..4a9aa61 100644 --- a/dcc/text.py +++ b/dcc/text.py @@ -3,36 +3,40 @@ import sys import wand.drawing import wand.image + def draw_text(img, text, font_size=64): - with wand.drawing.Drawing() as draw: - draw.font = dcc.config.FONT - draw.font_size=font_size - draw.fill_color=wand.color.Color(dcc.config.TEXT_FILL_COLOR) - draw.stroke_color=wand.color.Color(dcc.config.TEXT_STROKE_COLOR) - draw.stroke_width=font_size*5/32 - draw.text_interline_spacing=-font_size/4 - draw.text(5,int(draw.font_size)+5,text) - draw(img) - draw.stroke_color=wand.color.Color("none") - draw.stroke_width=0 - draw.text(5,int(draw.font_size)+5,text) - draw(img) + with wand.drawing.Drawing() as draw: + draw.font = dcc.config.FONT + draw.font_size = font_size + draw.fill_color = wand.color.Color(dcc.config.TEXT_FILL_COLOR) + draw.stroke_color = wand.color.Color(dcc.config.TEXT_STROKE_COLOR) + draw.stroke_width = font_size * 5 / 32 + draw.text_interline_spacing = -font_size / 4 + draw.text(5, int(draw.font_size) + 5, text) + draw(img) + draw.stroke_color = wand.color.Color("none") + draw.stroke_width = 0 + draw.text(5, int(draw.font_size)+5, text) + draw(img) class Text(dcc.doom_base.WadMap): - def get_parser(self, prog_name): - parser = super().get_parser(prog_name) - parser.add_argument("--nomap", action="store_true") - parser.add_argument("--demotype", default="UV-Max Demo") - return parser + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + parser.add_argument("--nomap", action="store_true") + parser.add_argument("--demotype", default="UV-Max Demo") + return parser - def take_action(self, parsed_args): - text = sys.stdin.read().rstrip() - if not parsed_args.nomap: - text = "MAP{}: {}".format(parsed_args.map, text) - text = "{}\n{}".format(text, parsed_args.demotype) - with wand.image.Image(height=dcc.config.THUMB_HEIGHT,width=dcc.config.THUMB_WIDTH) as img: - draw_text(img, text) - img.trim() - img.reset_coords() - img.save(filename=self.text_thumb_path()) + def take_action(self, parsed_args): + text = sys.stdin.read().rstrip() + if not parsed_args.nomap: + text = "MAP{}: {}".format(parsed_args.map, text) + text = "{}\n{}".format(text, parsed_args.demotype) + with wand.image.Image( + height=dcc.config.THUMB_HEIGHT, + width=dcc.config.THUMB_WIDTH + ) as img: + draw_text(img, text) + img.trim() + img.reset_coords() + img.save(filename=self.text_thumb_path()) From ebdac7c89d2d06b2e51e570e4d3e82be46c63d3b Mon Sep 17 00:00:00 2001 From: yrriban Date: Sun, 15 Jun 2025 13:33:33 -0400 Subject: [PATCH 7/7] PEP 8 compliance. --- dcc/thumb.py | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/dcc/thumb.py b/dcc/thumb.py index 9ff3b07..a1afa95 100644 --- a/dcc/thumb.py +++ b/dcc/thumb.py @@ -3,28 +3,34 @@ import dcc.doom_base import wand.color import wand.image + class Thumb(dcc.doom_base.WadMap): - def get_parser(self, prog_name): - parser = super().get_parser(prog_name) - parser.add_argument("--index", action="store_true") - return parser - - def take_action(self, parsed_args): - base = self.base_thumb_path() - text = self.text_thumb_path() - mdoom = self.m_doom_path() - with wand.image.Image(filename=base) as bi, wand.color.Color("transparent") as tc: - with wand.image.Image(filename=text) as ti: - ti.border(tc, 5, 5) - bi.composite(ti, gravity="south_west") + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + parser.add_argument("--index", action="store_true") + return parser - with wand.image.Image(filename=mdoom) as mdi: - mdi.border(tc, 5, 5) - bi.composite(mdi, gravity="north_west") + def take_action(self, parsed_args): + base = self.base_thumb_path() + text = self.text_thumb_path() + mdoom = self.m_doom_path() + with ( + wand.image.Image(filename=base) as bi, + wand.color.Color("transparent") as tc + ): + with wand.image.Image(filename=text) as ti: + ti.border(tc, 5, 5) + bi.composite(ti, gravity="south_west") - if parsed_args.index: - with wand.image.Image(filename=self.output.joinpath("doomed_index.png")) as di: - di.border(tc, 1, 1) - bi.composite(di, gravity="north_east") + with wand.image.Image(filename=mdoom) as mdi: + mdi.border(tc, 5, 5) + bi.composite(mdi, gravity="north_west") - bi.save(filename=self.thumb_path()) + if parsed_args.index: + with wand.image.Image( + filename=self.output.joinpath("doomed_index.png") + ) as di: + di.border(tc, 1, 1) + bi.composite(di, gravity="north_east") + + bi.save(filename=self.thumb_path())