From 6e1c7118f52ddfe3996d10038c72e3d80eb7aa83 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 10 May 2008 09:25:33 -0700 Subject: [PATCH] rtf-meta shouldn't raise exceptions on invalid RTF files --- src/calibre/ebooks/metadata/rtf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/metadata/rtf.py b/src/calibre/ebooks/metadata/rtf.py index 6a0d7ebb79..0eba36cffe 100644 --- a/src/calibre/ebooks/metadata/rtf.py +++ b/src/calibre/ebooks/metadata/rtf.py @@ -54,14 +54,14 @@ def get_document_info(stream): def get_metadata(stream): """ Return metadata as a L{MetaInfo} object """ + title, author, comment, category = None, None, None, None stream.seek(0) if stream.read(5) != r'{\rtf': - name = stream.name if hasattr(stream, 'name') else repr(stream) - raise Exception('Not a valid RTF file: '+name) + return MetaInformation(None, None) block = get_document_info(stream)[0] if not block: return MetaInformation(None, None) - title, author, comment, category = None, None, None, None + title_match = title_pat.search(block) if title_match: title = title_match.group(1).strip()