Commits

David Chambers committed b840fde

Renamed variables (`string` to `text`).

Comments (0)

Files changed (1)

templatetags/mango_extras.py

     return u'%s\n%s' % (title, '=' * len(title))
 
 @stringfilter
-def _convert(string):
+def _convert(text):
     md.reset()
-    return sanitize(md.convert(string))
+    return sanitize(md.convert(text))
 
 @register.filter
 @stringfilter
-def convert(string):
+def convert(text):
     md.reset()
-    return mark_safe(md.convert(string))
+    return mark_safe(md.convert(text))
 
 @register.filter
 @stringfilter
-def convert_html_chars(string):
-    return mark_safe(string.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;'))
+def convert_html_chars(text):
+    return mark_safe(text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;'))
 
-def display_date_or_time(string, format_as):
+def display_date_or_time(text, format_as):
     '''
     Python does not support 'am' and 'pm' in time format strings (only their uppercase equivalents).
     Nor does Python accommodate hours in the form '1', '2', '3', etc. (only '01', '02', '03', etc.).
     Python does not provide a directive for outputting ordinal dates (1st, 2nd, 3rd, etc.).
     The display_date and display_time filters support ordinal dates via the `%o` directive.
     '''
-    string = string[:-6] if string.endswith('+00:00') else string
+    text = text[:-6] if text.endswith('+00:00') else text
 
     try:
-        struct_time = time.strptime(string, '%Y-%m-%d %H:%M:%S')
+        struct_time = time.strptime(text, '%Y-%m-%d %H:%M:%S')
     except ValueError:
-        return string
+        return text
 
     if format_as == 'date':
         format = DISPLAY_DATE_FORMAT
     format = re.sub(r'(?<!%)%D', '%d', format) # default
     format = re.sub(r'(?<!%)%o', '{{%d|ordinal}}', format)
 
-    string = utf8(time.strftime(format.encode('utf-8'), struct_time))
+    text = utf8(time.strftime(format.encode('utf-8'), struct_time))
 
     def ordinal(n):
         if 10 < n < 14: return u'%sth' % n
         return u'%sth' % n
 
     funcs = {
-        'ordinal': lambda string: ordinal(int(string)),
-        'unpad': lambda string: string[1:] if string.startswith('0') else string,
-        'upper': lambda string: string.upper(),
-        'lower': lambda string: string.lower(),
+        'ordinal': lambda text: ordinal(int(text)),
+        'unpad': lambda text: text[1:] if text.startswith('0') else text,
+        'upper': lambda text: text.upper(),
+        'lower': lambda text: text.lower(),
     }
 
     return re.sub(r'{{(\w\w)\|(%s)}}' % '|'.join(funcs.keys()),
-            lambda m: funcs[m.group(2)](m.group(1)), string)
+            lambda m: funcs[m.group(2)](m.group(1)), text)
 
 @register.filter
 @stringfilter
-def display_date(string):
-    return display_date_or_time(string, 'date')
+def display_date(text):
+    return display_date_or_time(text, 'date')
 
 @register.filter
 @stringfilter
-def display_time(string):
-    return display_date_or_time(string, 'time')
+def display_time(text):
+    return display_date_or_time(text, 'time')
 
 @register.filter
 @stringfilter
 
 @register.filter
 @stringfilter
-def smart_capfirst(string):
-    if string.islower():
-        string = string[0].upper() + string[1:]
-    return string
+def smart_capfirst(text):
+    if text.islower():
+        text = text[0].upper() + text[1:]
+    return text
 
 @register.filter
 @stringfilter