PEP 8 compliance.
This commit is contained in:
parent
3f1dad2b43
commit
b54b865977
1 changed files with 36 additions and 20 deletions
|
@ -4,6 +4,7 @@ import numpy as np
|
|||
import wand.color
|
||||
import wand.image
|
||||
|
||||
|
||||
class Extract(dcc.config.base):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
@ -12,19 +13,34 @@ class Extract(dcc.config.base):
|
|||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
wads = sorted(self.pwads.joinpath(self.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:
|
||||
# TODO: handle anything other than graphics.
|
||||
wad = omg.WadIO(w)
|
||||
gl = omg.Graphic(wad.read(parsed_args.lump))
|
||||
# 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:
|
||||
# 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=self.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))
|
||||
print(
|
||||
f"Wad {w} likely has no lump {parsed_args.lump}"
|
||||
+ f"(exception {e})."
|
||||
)
|
||||
|
||||
print("Lump {} not found in any wad in {}".format(parsed_args.lump, parsed_args.wad))
|
||||
print(
|
||||
"Lump {parsed_args.lump} not found in any wad in"
|
||||
+ f"{parsed_args.wad}"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue