comparison gpp/smiley/__init__.py @ 286:72fd300685d5

For #95. You can now make posts with no text in the body if you have attachments. And now if you create a new topic with an attachment, and the POST fails (say you forgot the topic title), we will now re-attach attachments. Also fixed a bug in the smiley code that would arise if it was asked to markup an empty string.
author Brian Neal <bgneal@gmail.com>
date Sat, 23 Oct 2010 20:19:46 +0000
parents 3a626c48e9ae
children
comparison
equal deleted inserted replaced
285:8fd4984d5c3b 286:72fd300685d5
20 def convert(self, value, autoescape=False): 20 def convert(self, value, autoescape=False):
21 """ 21 """
22 Converts and returns the supplied text with the HTML version of the 22 Converts and returns the supplied text with the HTML version of the
23 smileys. 23 smileys.
24 """ 24 """
25 if not value:
26 return u''
27
25 if not autoescape or isinstance(value, SafeData): 28 if not autoescape or isinstance(value, SafeData):
26 esc = lambda x: x 29 esc = lambda x: x
27 else: 30 else:
28 esc = conditional_escape 31 esc = conditional_escape
29 32
47 def convert(self, s): 50 def convert(self, s):
48 """ 51 """
49 Returns a string copy of the input s that has the smiley codes replaced 52 Returns a string copy of the input s that has the smiley codes replaced
50 with Markdown for smiley images. 53 with Markdown for smiley images.
51 """ 54 """
55 if not s:
56 return u''
57
52 for regex, repl in self.regexes: 58 for regex, repl in self.regexes:
53 s = regex.sub(repl, s) 59 s = regex.sub(repl, s)
54 return s 60 return s
55 61
56 62