py3 does not have string.letters

This commit is contained in:
j 2015-12-25 20:43:15 +05:30
parent 1db297169b
commit c49f663d54

View file

@ -6,8 +6,10 @@ import string
from six.moves.html_entities import name2codepoint
from six import unichr, PY2, string_types
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
# Configuration for add_links() function
LEADING_PUNCTUATION = ['(', '<', '&lt;']
TRAILING_PUNCTUATION = ['.', ',', ')', '>', '\n', '&gt;', "'", '"']
@ -89,7 +91,7 @@ def add_links(text, trim_url_limit=None, nofollow=False):
if match:
lead, middle, trail = match.groups()
if middle.startswith('www.') or ('@' not in middle and not middle.startswith('http://') and \
len(middle) > 0 and middle[0] in string.letters + string.digits and \
len(middle) > 0 and middle[0] in letters + string.digits and \
(middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))):
middle = '<a href="http://%s"%s>%s</a>' % (middle, nofollow_attr, trim_url(middle))
if middle.startswith('http://') or middle.startswith('https://'):