Add a generator for DSDA zip files.
This commit is contained in:
parent
dd3a185f4b
commit
6a6f25aebc
3 changed files with 47 additions and 0 deletions
|
@ -59,6 +59,9 @@ def DemoInPath(wad, mapstr):
|
||||||
return candidates[0]
|
return candidates[0]
|
||||||
return sorted(filter(lambda s : re.search("-", str(s)), candidates))[-1]
|
return sorted(filter(lambda s : re.search("-", str(s)), candidates))[-1]
|
||||||
|
|
||||||
|
def DsdaTextPath(wad, mapstr):
|
||||||
|
return Ensure(DEMOS.joinpath(wad)).joinpath("{}_map{}.txt".format(wad, mapstr))
|
||||||
|
|
||||||
def DemoOutPath(wad, mapstr):
|
def DemoOutPath(wad, mapstr):
|
||||||
return Ensure(DEMOS.joinpath(wad)).joinpath(DemoName(wad, mapstr))
|
return Ensure(DEMOS.joinpath(wad)).joinpath(DemoName(wad, mapstr))
|
||||||
|
|
||||||
|
|
43
dcc/dsda.py
Normal file
43
dcc/dsda.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import dcc.config
|
||||||
|
import dcc.doom_base
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
class DSDA(dcc.doom_base.WadMap):
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super().get_parser(prog_name)
|
||||||
|
parser.add_argument("-s", "--single", action="store_true")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
dip = dcc.config.DemoInPath(parsed_args.wad, parsed_args.map)
|
||||||
|
dtp = dcc.config.DsdaTextPath(parsed_args.wad, parsed_args.map)
|
||||||
|
if not dtp.exists():
|
||||||
|
subprocess.run([dcc.config.DSDA] +
|
||||||
|
dcc.config.DsdaPreamble(parsed_args.wad, parsed_args.map) +
|
||||||
|
["-playdemo", dip, "-export_text_file"])
|
||||||
|
editor = "nano"
|
||||||
|
if "EDITOR" in os.environ:
|
||||||
|
editor = os.environ["EDITOR"]
|
||||||
|
subprocess.run([editor, dtp])
|
||||||
|
fh1 = parsed_args.wad[0:2] + parsed_args.map
|
||||||
|
if parsed_args.single:
|
||||||
|
fh1 = parsed_args.wad[0:min(len(parsed_args.wad, 4))]
|
||||||
|
fh2 = ""
|
||||||
|
with open(dtp, mode="r") as f:
|
||||||
|
for line in f:
|
||||||
|
if line[0:4] == "Time":
|
||||||
|
m = re.search("[^0-9]*([0-9]*):([0-9]*).[0-9]*", line)
|
||||||
|
if m is None:
|
||||||
|
continue
|
||||||
|
fh2 = m[1]+m[2]
|
||||||
|
if not fh2:
|
||||||
|
sys.exit("Failed to match any line in {} against Time regex.".format(dtp))
|
||||||
|
|
||||||
|
# TODO: demo names other than uv-max.
|
||||||
|
fnf = fh1 + "-" + fh2 + ".zip"
|
||||||
|
with zipfile.ZipFile(dcc.config.DEMOS.joinpath(parsed_args.wad).joinpath(fnf), mode="w") as zf:
|
||||||
|
zf.write(dip, arcname=dip.name)
|
||||||
|
zf.write(dtp, arcname=dtp.name)
|
1
setup.py
1
setup.py
|
@ -32,6 +32,7 @@ setup(
|
||||||
'fetch = dcc.fetch:Fetch',
|
'fetch = dcc.fetch:Fetch',
|
||||||
'text = dcc.text:Text',
|
'text = dcc.text:Text',
|
||||||
'thumb = dcc.thumb:Thumb',
|
'thumb = dcc.thumb:Thumb',
|
||||||
|
'dsda = dcc.dsda:DSDA',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue