changeset 5194:d60f54b3eeb3

helpers: extract internal _urlify_text function from urlify_text
author Mads Kiilerich <madski@unity3d.com>
date Fri, 19 Jun 2015 18:00:42 +0200
parents 82198c193c11
children 53f19cdfa40c
files kallithea/lib/helpers.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/helpers.py	Fri Jun 19 18:00:42 2015 +0200
+++ b/kallithea/lib/helpers.py	Fri Jun 19 18:00:42 2015 +0200
@@ -1264,21 +1264,21 @@
     return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d))
 
 
-def urlify_text(text_, safe=True):
+def _urlify_text(s):
     """
     Extract urls from text and make html links out of them
-
-    :param text_:
     """
-
     def url_func(match_obj):
-        url_full = match_obj.groups()[0]
+        url_full = match_obj.group(1)
         return '<a href="%(url)s">%(url)s</a>' % ({'url': url_full})
-    _newtext = url_re.sub(url_func, text_)
-    if safe:
-        return literal(_newtext)
-    return _newtext
+    return url_re.sub(url_func, s)
 
+def urlify_text(s):
+    """
+    Extract urls from text and make literal html links out of them
+    """
+    s = _urlify_text(s)
+    return literal(s)
 
 def urlify_changesets(text_, repository):
     """
@@ -1325,7 +1325,7 @@
     newtext = urlify_changesets(newtext, repository)
 
     # extract http/https links and make them real urls
-    newtext = urlify_text(newtext, safe=False)
+    newtext = _urlify_text(newtext)
 
     newtext = urlify_issues(newtext, repository, link_)