From c5a6b3627338d60db852c84424dac854db74c299 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 11 Oct 2011 18:51:28 +0200 Subject: [PATCH] fix a bug in get_sort_title with articles that end with a single quote --- ox/text.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ox/text.py b/ox/text.py index 6fb8a14..8af2a00 100644 --- a/ox/text.py +++ b/ox/text.py @@ -108,11 +108,15 @@ def get_sort_title(title): >>> get_sort_title('Die Hard') 'Hard, Die' + >>> get_sort_title("L'atalante") + "atalante, L'" + """ for article in ARTICLES: - if title.lower().startswith(article + ' '): + spaces = 0 if article.endswith("'") else 1 + if title.lower().startswith(article + ' ' * spaces): length = len(article) - return title[length + 1:] + ', ' + title[:length] + return title[length + spaces:] + ', ' + title[:length] return title def findRe(string, regexp):