PEP 8 compliance.

This commit is contained in:
yrriban 2025-06-15 01:11:01 -04:00
parent ff384678de
commit e5656378ac

View file

@ -6,51 +6,59 @@ import shutil
import subprocess import subprocess
import zipfile import zipfile
class DSDA(dcc.doom_base.WadMap): class DSDA(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)
parser.add_argument("-s", "--single", action="store_true") parser.add_argument("-s", "--single", action="store_true")
parser.add_argument("-a", "--abbreviation") parser.add_argument("-a", "--abbreviation")
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
dip = self.demo_in_path() dip = self.demo_in_path()
dtp = self.dsda_text_path() dtp = self.dsda_text_path()
if not dtp.exists(): if not dtp.exists():
command = [self.dsda] command = [self.dsda]
if shutil.which("xvfb-run") is not None: if shutil.which("xvfb-run") is not None:
command = ["xvfb-run"] + command command = ["xvfb-run"] + command
# TODO: negative tics should seek from the end, but this doesn't seem to work. # TODO: negative tics should seek from the end, but this doesn't
subprocess.run(command + self.dsda_preamble() + # seem to work.
["-fastdemo", dip, "-nosound", "-skiptic", "999999999", "-export_text_file"]) subprocess.run(
editor = "nano" command + self.dsda_preamble() + [
if "EDITOR" in os.environ: "-fastdemo", dip, "-nosound", "-skiptic",
editor = os.environ["EDITOR"] "999999999", "-export_text_file"
subprocess.run([editor, dtp]) ]
if parsed_args.abbreviation: )
fh1 = parsed_args.abbreviation editor = "nano"
if not parsed_args.single: if "EDITOR" in os.environ:
fh1 += self.map editor = os.environ["EDITOR"]
else: subprocess.run([editor, dtp])
fh1 = self.wad[0:2] + self.map if parsed_args.abbreviation:
if parsed_args.single: fh1 = parsed_args.abbreviation
fh1 = self.wad[0:min(len(self.wad), 4)] if not parsed_args.single:
fh2 = "" fh1 += self.map
with open(dtp, mode="r") as f: else:
for line in f: fh1 = self.wad[0:2] + self.map
if line[0:4] == "Time": if parsed_args.single:
m = re.search("[^0-9]*([0-9]*):([0-9]*).[0-9]*", line) fh1 = self.wad[0:min(len(self.wad), 4)]
if m is None: fh2 = ""
continue with open(dtp, mode="r") as f:
fh2 = m[1]+m[2] for line in f:
if len(fh2)%2==1: if line[0:4] == "Time":
fh2 = "0" + fh2 m = re.search("[^0-9]*([0-9]*):([0-9]*).[0-9]*", line)
break if m is None:
if not fh2: continue
sys.exit("Failed to match any line in {} against Time regex.".format(dtp)) fh2 = m[1]+m[2]
if len(fh2) % 2 == 1:
fh2 = "0" + fh2
break
if not fh2:
sys.exit(f"Failed to match any line in {dtp} against Time regex.")
# TODO: demo names other than uv-max. # TODO: demo names other than uv-max.
fnf = fh1 + "-" + fh2 + ".zip" fnf = fh1 + "-" + fh2 + ".zip"
with zipfile.ZipFile(self.demos.joinpath(self.wad).joinpath(fnf), mode="w") as zf: with zipfile.ZipFile(
zf.write(dip, arcname=dip.name) self.demos.joinpath(self.wad).joinpath(fnf), mode="w"
zf.write(dtp, arcname=dtp.name) ) as zf:
zf.write(dip, arcname=dip.name)
zf.write(dtp, arcname=dtp.name)