Read COMPLVL lump on initial configuration #9
2 changed files with 17 additions and 8 deletions
|
|
@ -1,11 +1,12 @@
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
|
import omg
|
||||||
import tomlkit.toml_file
|
import tomlkit.toml_file
|
||||||
|
|
||||||
|
|
||||||
class Configure(dcc.doom_base.Wad):
|
class Configure(dcc.doom_base.Wad):
|
||||||
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("complevel")
|
parser.add_argument("--complevel", "--cl")
|
||||||
parser.add_argument("--iwad")
|
parser.add_argument("--iwad")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
@ -14,8 +15,21 @@ class Configure(dcc.doom_base.Wad):
|
||||||
if new_config.exists():
|
if new_config.exists():
|
||||||
raise Exception(f"Config {new_config} already exists.")
|
raise Exception(f"Config {new_config} already exists.")
|
||||||
|
|
||||||
|
complevel = parsed_args.complevel
|
||||||
|
if complevel is None:
|
||||||
|
for w in self.load_order():
|
||||||
|
try:
|
||||||
|
wad = omg.WadIO(w)
|
||||||
|
complevel = wad.read("COMPLVL").decode("ascii").strip()
|
||||||
|
except Exception as e:
|
||||||
|
print(
|
||||||
|
f"Wad {w} likely has no lump COMPLVL (exception {e})")
|
||||||
|
if complevel is None:
|
||||||
|
complevel = input("Complevel? ")
|
||||||
|
|
||||||
|
|
||||||
doc = tomlkit.document()
|
doc = tomlkit.document()
|
||||||
doc.add("complevel", parsed_args.complevel)
|
doc.add("complevel", complevel)
|
||||||
if parsed_args.iwad is not None:
|
if parsed_args.iwad is not None:
|
||||||
doc.add("iwad", parsed_args.iwad)
|
doc.add("iwad", parsed_args.iwad)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,7 @@ class Extract(dcc.doom_base.Wad):
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
wads = sorted(
|
for w in self.load_order()
|
||||||
self.pwads.joinpath(self.wad).glob('*.wad', case_sensitive=False),
|
|
||||||
reverse=True
|
|
||||||
)
|
|
||||||
|
|
||||||
for w in wads:
|
|
||||||
try:
|
try:
|
||||||
# TODO: handle anything other than graphics.
|
# TODO: handle anything other than graphics.
|
||||||
wad = omg.WadIO(w)
|
wad = omg.WadIO(w)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue