Mercurial > public > src > rhodecode
diff pylons_app/lib/helpers.py @ 491:c3236d7febad
fixed, empty cs bug.
Implemented as webhlepers function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 03 Sep 2010 09:55:48 +0200 |
parents | 4679105ef03e |
children | 4187d93c7c04 |
line wrap: on
line diff
--- a/pylons_app/lib/helpers.py Fri Sep 03 09:23:50 2010 +0200 +++ b/pylons_app/lib/helpers.py Fri Sep 03 09:55:48 2010 +0200 @@ -219,7 +219,7 @@ pygmentize function using pygments @param filenode: """ - return literal(code_highlight(filenode.content, + return literal(code_highlight(filenode.content, filenode.lexer, HtmlFormatter(**kwargs))) def pygmentize_annotation(filenode, **kwargs): @@ -239,11 +239,11 @@ h = 0.22717784590367374 #generate 10k nice web friendly colors in the same order for c in xrange(n): - h +=golden_ratio + h += golden_ratio h %= 1 HSV_tuple = [h, 0.95, 0.95] RGB_tuple = colorsys.hsv_to_rgb(*HSV_tuple) - yield map(lambda x:str(int(x*256)),RGB_tuple) + yield map(lambda x:str(int(x * 256)), RGB_tuple) cgenerator = gen_color() @@ -255,7 +255,7 @@ return "color: rgb(%s)! important;" % (', '.join(col)) def url_func(changeset): - tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>"+\ + tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>" + \ " %s<br/><b>Date:</b> %s</b><br/><b>Message:</b> %s<br/></div>" tooltip_html = tooltip_html % (changeset.author, @@ -286,6 +286,21 @@ slug = recursive_replace(slug, '-') return slug +def get_changeset_safe(repo, rev): + from vcs.backends.base import BaseRepository + from vcs.exceptions import RepositoryError + if not isinstance(repo, BaseRepository): + raise Exception('You must pass an Repository ' + 'object as first argument got %s', type(repo)) + + try: + cs = repo.get_changeset(rev) + except RepositoryError: + from pylons_app.lib.utils import EmptyChangeset + cs = EmptyChangeset() + return cs + + flash = _Flash() @@ -351,4 +366,4 @@ #incase we have a decode error just represent as byte string u_str = unicode(str(str).encode('string_escape')) - return u_str \ No newline at end of file + return u_str