Refine slug algorithm further.

This commit is contained in:
Thomas Gideon 2011-09-29 16:30:55 -04:00
parent b111bd12e3
commit a304e238a6

View file

@ -232,14 +232,21 @@ def __archive_slug(title):
slug = re.sub('\([^0-9]\)-\([^0-9]\)', '\1\2', title)
slug = re.sub(u'\u2013', '-', slug)
slug = re.sub(u'\u2019', '', slug)
slug = re.sub('[^A-Za-z0-9\-\.]', ' ', slug)
slug = re.sub('[^A-Za-z0-9\-\.(]', ' ', slug)
slug = re.sub(' {2,}', ' ', slug)
tokens = slug.split(' ')
tokens = [t.capitalize() for t in tokens]
tokens = [__paren_capitalize(t) for t in tokens]
slug = ''.join(tokens)
return slug
def __paren_capitalize(token):
if token.startswith('('):
token = token[1:]
return token.lower()
return token.capitalize()
def __main(feed_file):
logging.basicConfig(level=logging.INFO,
format='%(message)s')