Fix error message when invalid format is given

This commit is contained in:
910JQK 2016-08-13 17:20:02 +08:00
parent 4477a56810
commit 234d43cc01

View File

@ -754,10 +754,16 @@ def ReadComments(input_files, input_format, font_size=25.0, progress_callback=No
str_io = io.StringIO(s)
if input_format == 'autodetect':
CommentProcessor = GetCommentProcessor(str_io)
if not CommentProcessor:
raise ValueError(
_('Failed to detect comment file format: %s') % i
)
else:
CommentProcessor = CommentFormatMap.get(input_format)
if not CommentProcessor:
raise ValueError(_('Unknown comment file format: %s') % i)
raise ValueError(
_('Unknown comment file format: %s') % input_format
)
comments.extend(CommentProcessor(FilterBadChars(str_io), font_size))
if progress_callback:
progress_callback(len(input_files), len(input_files))