From dde6654bdb9d69960077d95f2715fc29ef1024d9 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Sat, 28 Sep 2024 08:08:43 +0100 Subject: [PATCH] img: Alow auto-detected formats to be overridden on command line --- src/greaseweazle/image/img.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/greaseweazle/image/img.py b/src/greaseweazle/image/img.py index 76f5c70b..99dc1a4f 100644 --- a/src/greaseweazle/image/img.py +++ b/src/greaseweazle/image/img.py @@ -100,11 +100,10 @@ def format_from_file(name: str) -> str: @classmethod def from_file(cls, name: str, fmt: Optional[codec.DiskDef], opts: OptDict) -> Image: - error.check(fmt is None, - f'{cls.__name__}: Format cannot be overridden') - format_str = cls.format_from_file(name) - fmt = codec.get_diskdef(format_str) - print(f'{cls.__name__}: Image format {format_str}') + if fmt is None: + format_str = cls.format_from_file(name) + fmt = codec.get_diskdef(format_str) + print(f'{cls.__name__}: Image format {format_str}') return super().from_file(name, fmt, opts) # Local variables: