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
|
@ -1,11 +1,10 @@
|
|||
from cliff.command import Command
|
||||
import dcc.config
|
||||
import omg
|
||||
import numpy as np
|
||||
import wand.color
|
||||
import wand.image
|
||||
|
||||
class Extract(Command):
|
||||
class Extract(dcc.config.base):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument('wad')
|
||||
|
@ -13,7 +12,7 @@ class Extract(Command):
|
|||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
wads = sorted(dcc.config.PWADS.joinpath(parsed_args.wad).glob('*.wad', case_sensitive=False), reverse=True)
|
||||
wads = sorted(self.pwads.joinpath(self.wad).glob('*.wad', case_sensitive=False), reverse=True)
|
||||
|
||||
for w in wads:
|
||||
try:
|
||||
|
@ -23,7 +22,7 @@ class Extract(Command):
|
|||
# With no arguments, convert() changes a paletted image to an RGB one.
|
||||
with wand.image.Image.from_array(np.array(gl.to_Image().convert())) as img:
|
||||
img.transparent_color(wand.color.Color("#ff00ff"), 0.0)
|
||||
img.save(filename=dcc.config.OUTPUT.joinpath(parsed_args.wad).joinpath(parsed_args.lump + ".png"))
|
||||
img.save(filename=self.output.joinpath(parsed_args.wad).joinpath(parsed_args.lump + ".png"))
|
||||
return
|
||||
except Exception as e:
|
||||
print("Wad {} likely has no lump {} (exception {}).".format(w, parsed_args.lump, e))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue