Read values out of a config file instead of hardcoding them. Further streamline common tasks in a new base config class.
This commit is contained in:
parent
606f27185c
commit
057ac98843
11 changed files with 83 additions and 69 deletions
|
|
@ -2,6 +2,7 @@ from abc import abstractmethod
|
|||
from cliff.command import Command
|
||||
import dcc.config
|
||||
import io
|
||||
import os
|
||||
|
||||
class WadMap(dcc.config.Base):
|
||||
def get_parser(self, prog_name):
|
||||
|
|
@ -15,11 +16,7 @@ class WadMap(dcc.config.Base):
|
|||
self._wad = parsed_args.wad
|
||||
self._map = parsed_args.map
|
||||
self._name = parsed_args.name
|
||||
self.take_action(parsed_args)
|
||||
|
||||
@abstractmethod
|
||||
def take_action(self, parsed_args):
|
||||
pass
|
||||
super().run(parsed_args)
|
||||
|
||||
@property
|
||||
def wad(self):
|
||||
|
|
@ -34,9 +31,9 @@ class WadMap(dcc.config.Base):
|
|||
return "" if self._name is None else "_" + self._name
|
||||
|
||||
def dsda_preamble(self):
|
||||
args = ["-iwad", dcc.config.IwadPath(self.wad)]
|
||||
args = ["-iwad", self.iwad_path(self.wad)]
|
||||
|
||||
pwadpath = dcc.config.PWADS.joinpath(self.wad)
|
||||
pwadpath = self.pwads.joinpath(self.wad)
|
||||
wads = sorted(pwadpath.glob('*.wad', case_sensitive=False))
|
||||
if len(wads) > 0:
|
||||
args = args + ["-file"] + wads
|
||||
|
|
@ -45,19 +42,21 @@ class WadMap(dcc.config.Base):
|
|||
if len(dehs) > 0:
|
||||
args = args + ["-deh"] + dehs
|
||||
|
||||
complevel = pwadpath.joinpath("complevel")
|
||||
if not complevel.exists():
|
||||
raise Exception("No complevel set in PWAD dir {}.".format(pwadpath))
|
||||
|
||||
with io.open(complevel) as f:
|
||||
args = args + ["-complevel", dcc.config.Complevel(self.wad)]
|
||||
|
||||
args = args + ["-complevel", self.complevel()]
|
||||
args = args + ["-skill", "4"]
|
||||
args = args + ["-warp", self.map]
|
||||
return args
|
||||
|
||||
def complevel(self):
|
||||
complevel = self.pwads.joinpath(self.wad).joinpath("complevel")
|
||||
if not complevel.exists():
|
||||
raise Exception("No complevel set in PWAD dir {}.".format(pwadpath))
|
||||
|
||||
with io.open(complevel) as f:
|
||||
return f.read().strip()
|
||||
|
||||
def demo_in_path(self):
|
||||
candidates = [x for x in dcc.config.DEMOS.joinpath(self.wad).glob(self._file_base("*.lmp"))]
|
||||
candidates = [x for x in self.demos.joinpath(self.wad).glob(self._file_base("*.lmp"))]
|
||||
if len(candidates) == 0:
|
||||
raise Exception("no suitable demo candidates for WAD {} MAP {} name {}.".format(self.wad, self.map, self.name_string))
|
||||
if len(candidates) == 1:
|
||||
|
|
@ -65,28 +64,28 @@ class WadMap(dcc.config.Base):
|
|||
return sorted(filter(lambda s : re.search("-", str(s)), candidates))[-1]
|
||||
|
||||
def dsda_text_path(self):
|
||||
return self._ensure(dcc.config.DEMOS.joinpath(self.wad)).joinpath(self._file_base(".txt"))
|
||||
return self._ensure(self.demos.joinpath(self.wad)).joinpath(self._file_base(".txt"))
|
||||
|
||||
def video_path(self):
|
||||
return self._ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(self._file_base(".mp4"))
|
||||
return self._ensure(self.fabricate.joinpath(self.wad)).joinpath(self._file_base(".mp4"))
|
||||
|
||||
def demo_out_path(self):
|
||||
return self._ensure(dcc.config.DEMOS.joinpath(self.wad)).joinpath(self._file_base(".lmp"))
|
||||
return self._ensure(self.demos.joinpath(self.wad)).joinpath(self._file_base(".lmp"))
|
||||
|
||||
def target_bucket(self):
|
||||
return "doom/" + self._file_base(".lmp")
|
||||
|
||||
def base_thumb_path(self):
|
||||
return self._ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(_file_base("_base.png"))
|
||||
return self._ensure(self.fabricate.joinpath(self.wad)).joinpath(self._file_base("_base.png"))
|
||||
|
||||
def m_doom_path(self):
|
||||
return self._ensure(OUTPUT.joinpath(self.wad)).joinpath("M_DOOM_scaled.png")
|
||||
return self._ensure(self.fabricate.joinpath(self.wad)).joinpath("M_DOOM_scaled.png")
|
||||
|
||||
def text_thumb_path(self):
|
||||
return self._ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(_file_base("_text.png"))
|
||||
return self._ensure(self.fabricate.joinpath(self.wad)).joinpath(self._file_base("_text.png"))
|
||||
|
||||
def thumb_path(self):
|
||||
return self._ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(_file_base("_thumb.png"))
|
||||
return self._ensure(self.fabricate.joinpath(self.wad)).joinpath(self._file_base("_thumb.png"))
|
||||
|
||||
def _file_base(self, ext):
|
||||
return "{}_map{}{}{}".format(self.wad, self.map, self.name_string, ext)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue