# HG changeset patch # User Marcin Kuzminski # Date 2016-06-22 09:32:13 # Node ID 339501a7ab570af684154a909f5cc678f3f2d0a3 # Parent 8089e575a3fe903927a6a7bc88b312e3f8c82e4b helpers: fixed some errors on helpers, and removed dead code. diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -438,15 +438,17 @@ def get_matching_line_offsets(lines, ter :param max_lines: cut off for lines of interest eg. - >>> get_matching_line_offsets(''' -words words words -words words words -some text some -words words words -words words words -text here what -''', 'text', context=1) + text = ''' + words words words + words words words + some text some + words words words + words words words + text here what + ''' + get_matching_line_offsets(text, 'text', context=1) {3: [(5, 9)], 6: [(0, 4)]] + """ matching_lines = {} phrases = [normalize_text_for_matching(phrase) @@ -460,6 +462,7 @@ text here what return matching_lines + def get_lexer_safe(mimetype=None, filepath=None): """ Tries to return a relevant pygments lexer using mimetype/filepath name, @@ -470,7 +473,7 @@ def get_lexer_safe(mimetype=None, filepa if mimetype: lexer = get_lexer_for_mimetype(mimetype) if not lexer: - lexer = get_lexer_for_filename(path) + lexer = get_lexer_for_filename(filepath) except pygments.util.ClassNotFound: pass @@ -675,11 +678,6 @@ def _shorten_commit_id(commit_id): return commit_id[:def_len] -def get_repo_id_from_name(repo_name): - repo = get_by_repo_name(repo_name) - return repo.repo_id - - def show_id(commit): """ Configurable function that shows ID @@ -858,7 +856,7 @@ def desc_stylize(value): value = re.sub(r'\[(lang|language)\ \=\>\ *([a-zA-Z\-\/\#\+]*)\]', '
\\2
', value) value = re.sub(r'\[([a-z]+)\]', - '
\\1
', value) + '
\\1
', value) return value @@ -883,7 +881,7 @@ def escaped_stylize(value): value = re.sub(r'\[(lang|language)\ \=\>\ *([a-zA-Z\-\/\#\+]*)\]', '
\\2
', value) value = re.sub(r'\[([a-z]+)\]', - '
\\1
', value) + '
\\1
', value) return value