From 2532de27fb50695e9b52b72683703a1b169b6c65 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Nov 2011 22:49:09 +0530 Subject: [PATCH] Do not error out if there is an invalid regex for title sort set in tweaks --- src/calibre/ebooks/metadata/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index decba3b780..a6b3c1ad21 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -116,10 +116,14 @@ def title_sort(title, order=None): title = title[1:] match = _title_pat.search(title) if match: - prep = match.group(1) - title = title[len(prep):] + ', ' + prep - if title[0] in _ignore_starts: - title = title[1:] + try: + prep = match.group(1) + except IndexError: + pass + else: + title = title[len(prep):] + ', ' + prep + if title[0] in _ignore_starts: + title = title[1:] return title.strip() coding = zip(