Skip to content

Commit 0936865

Browse files
committed
examples/deepzoom: enforce --format enum in argparse
Give clearer feedback if the argument is invalid. For the WSGI programs we need to continue enforcing validity outside of argparse, since the value may be set by other means. Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent 2a040ab commit 0936865

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

examples/deepzoom/deepzoom_multiserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ def __init__(self, relpath: str):
356356
parser.add_argument(
357357
'-f',
358358
'--format',
359-
metavar='{jpeg|png}',
360359
dest='DEEPZOOM_FORMAT',
360+
choices=['jpeg', 'png'],
361361
help='image format for tiles [jpeg]',
362362
)
363363
parser.add_argument(

examples/deepzoom/deepzoom_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ def xfrm(img: Image.Image) -> None:
293293
parser.add_argument(
294294
'-f',
295295
'--format',
296-
metavar='{jpeg|png}',
297296
dest='DEEPZOOM_FORMAT',
297+
choices=['jpeg', 'png'],
298298
help='image format for tiles [jpeg]',
299299
)
300300
parser.add_argument(

examples/deepzoom/deepzoom_tile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ def _shutdown(self) -> None:
426426
parser.add_argument(
427427
'-f',
428428
'--format',
429-
metavar='{jpeg|png}',
430429
dest='format',
431430
default='jpeg',
431+
choices=['jpeg', 'png'],
432432
help='image format for tiles [jpeg]',
433433
)
434434
parser.add_argument(

0 commit comments

Comments
 (0)