Add a pwad_path property and also convert the iwad_path method to a property.

This commit is contained in:
yrriban 2025-07-03 18:21:24 -04:00
parent 5881c94c11
commit b14c12c609
3 changed files with 12 additions and 7 deletions

View file

@ -2,6 +2,7 @@ import dcc.config
import tomlkit import tomlkit
from tomlkit.toml_file import TOMLFile from tomlkit.toml_file import TOMLFile
class Configure(dcc.config.Base): class Configure(dcc.config.Base):
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super().get_parser(prog_name) parser = super().get_parser(prog_name)
@ -11,7 +12,7 @@ class Configure(dcc.config.Base):
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
new_config = self.pwads.joinpath(parsed_args.wad).joinpath(self.config_name) new_config = self.pwad_path.joinpath(self.config_name)
if new_config.exists(): if new_config.exists():
raise Exception("Config %s already exists.".format(new_config)) raise Exception("Config %s already exists.".format(new_config))

View file

@ -29,9 +29,14 @@ class Wad(dcc.config.Base):
def wad(self): def wad(self):
return self._wad return self._wad
@property
def pwad_path(self):
return self.pwads.joinpath(self.wad)
@property
def iwad_path(self): def iwad_path(self):
iwad = self.iwads.joinpath(self._config.get("iwad")) iwad = self.iwads.joinpath(self._config.get("iwad"))
iwadpath = self.pwads.joinpath(self.wad).joinpath("iwad") iwadpath = self.pwad_path.joinpath("iwad")
if iwadpath.exists(): if iwadpath.exists():
with io.open(iwadpath) as f: with io.open(iwadpath) as f:
iwad = self.iwads.joinpath(f.read().strip() + ".WAD") iwad = self.iwads.joinpath(f.read().strip() + ".WAD")
@ -61,14 +66,13 @@ class WadMap(Wad):
return "" if self._name is None else "_" + self._name return "" if self._name is None else "_" + self._name
def dsda_preamble(self): def dsda_preamble(self):
args = ["-iwad", self.iwad_path()] args = ["-iwad", self.iwad_path]
pwadpath = self.pwads.joinpath(self.wad) wads = sorted(self.pwad_path.glob('*.wad', case_sensitive=False))
wads = sorted(pwadpath.glob('*.wad', case_sensitive=False))
if len(wads) > 0: if len(wads) > 0:
args = args + ["-file"] + wads args = args + ["-file"] + wads
dehs = sorted(pwadpath.glob('*.deh', case_sensitive=False)) dehs = sorted(self.pwad_path.glob('*.deh', case_sensitive=False))
if len(dehs) > 0: if len(dehs) > 0:
args = args + ["-deh"] + dehs args = args + ["-deh"] + dehs

View file

@ -10,7 +10,7 @@ class Eureka(dcc.doom_base.WadMap):
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
iwad = self.iwad_path() iwad = self.iwad_path
pwadpath = self.pwads.joinpath(parsed_args.wad) pwadpath = self.pwads.joinpath(parsed_args.wad)
if parsed_args.main is not None: if parsed_args.main is not None:
mw = pwadpath.joinpath(parsed_args.main) mw = pwadpath.joinpath(parsed_args.main)