Mercurial > kallithea
diff rhodecode/lib/__init__.py @ 1713:54687aa00724 beta
Tests updates, Session refactoring
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 23 Nov 2011 15:36:57 +0200 |
parents | 2755c11c90d8 |
children | cf51bbfb120e |
line wrap: on
line diff
--- a/rhodecode/lib/__init__.py Wed Nov 23 00:55:05 2011 +0200 +++ b/rhodecode/lib/__init__.py Wed Nov 23 15:36:57 2011 +0200 @@ -24,6 +24,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os +import re def __get_lem(): from pygments import lexers @@ -78,9 +79,9 @@ # extension together with weights to search lower is first RST_EXTS = [ - ('', 0), ('.rst', 1),('.rest', 1), - ('.RST', 2) ,('.REST', 2), - ('.txt', 3), ('.TXT', 3) + ('', 0), ('.rst', 1), ('.rest', 1), + ('.RST', 2) , ('.REST', 2), + ('.txt', 3), ('.TXT', 3) ] MARKDOWN_EXTS = [ @@ -90,7 +91,7 @@ ('.markdown', 4), ('.MARKDOWN', 4) ] -PLAIN_EXTS = [('.text', 2),('.TEXT', 2)] +PLAIN_EXTS = [('.text', 2), ('.TEXT', 2)] ALL_EXTS = MARKDOWN_EXTS + RST_EXTS + PLAIN_EXTS @@ -223,7 +224,7 @@ :rtype: str :returns: str object """ - + if not isinstance(unicode_, basestring): return str(unicode_) @@ -436,3 +437,14 @@ "was: %s" % err) return None +def extract_mentioned_users(s): + """ + Returns unique usernames from given string s that have @mention + + :param s: string to get mentions + """ + usrs = {} + for username in re.findall(r'(?:^@|\s@)(\w+)', s): + usrs[username] = username + + return sorted(usrs.keys())