fix a bug in get_sort_title with articles that end with a single quote

This commit is contained in:
rolux 2011-10-11 18:51:28 +02:00
parent 8b756b888a
commit c5a6b36273

View file

@ -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):