Mercurial > public > src > rhodecode
comparison pylons_app/lib/helpers.py @ 260:6ada8c223374
made global funcion to clean repo names, and remove all special chars from the name.
Switched message slug into webhelpers function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 06 Jun 2010 21:54:54 +0200 |
parents | be4621c6de58 |
children | 0e5455fda8fd |
comparison
equal
deleted
inserted
replaced
259:dee1913f7f5a | 260:6ada8c223374 |
---|---|
19 from webhelpers.number import format_byte_size, format_bit_size | 19 from webhelpers.number import format_byte_size, format_bit_size |
20 from webhelpers.pylonslib import Flash as _Flash | 20 from webhelpers.pylonslib import Flash as _Flash |
21 from webhelpers.pylonslib.secure_form import secure_form | 21 from webhelpers.pylonslib.secure_form import secure_form |
22 from webhelpers.text import chop_at, collapse, convert_accented_entities, \ | 22 from webhelpers.text import chop_at, collapse, convert_accented_entities, \ |
23 convert_misc_entities, lchop, plural, rchop, remove_formatting, \ | 23 convert_misc_entities, lchop, plural, rchop, remove_formatting, \ |
24 replace_whitespace, urlify | 24 replace_whitespace, urlify, truncate |
25 | 25 |
26 | 26 |
27 #Custom helper here :) | 27 #Custom helper here :) |
28 class _Link(object): | 28 class _Link(object): |
29 ''' | 29 ''' |
90 changeset.message,), | 90 changeset.message,), |
91 style=get_color_string(changeset.raw_id))) | 91 style=get_color_string(changeset.raw_id))) |
92 | 92 |
93 return literal(annotate_highlight(filenode, url_func, **kwargs)) | 93 return literal(annotate_highlight(filenode, url_func, **kwargs)) |
94 | 94 |
95 def recursive_replace(str, replace=' '): | |
96 """ | |
97 Recursive replace of given sign to just one instance | |
98 @param str: given string | |
99 @param replace:char to find and replace multiple instances | |
100 | |
101 Examples:: | |
102 >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') | |
103 'Mighty-Mighty-Bo-sstones' | |
104 """ | |
105 | |
106 if str.find(replace * 2) == -1: | |
107 return str | |
108 else: | |
109 str = str.replace(replace * 2, replace) | |
110 return recursive_replace(str, replace) | |
111 | |
112 def repo_name_slug(value): | |
113 """ | |
114 Return slug of name of repository | |
115 """ | |
116 slug = urlify(value) | |
117 for c in """=[]\;',/~!@#$%^&*()+{}|:""": | |
118 slug = slug.replace(c, '-') | |
119 print slug | |
120 slug = recursive_replace(slug, '-') | |
121 print slug | |
122 return slug | |
123 | |
95 files_breadcrumbs = _FilesBreadCrumbs() | 124 files_breadcrumbs = _FilesBreadCrumbs() |
96 link = _Link() | 125 link = _Link() |
97 flash = _Flash() | 126 flash = _Flash() |
98 get_error = _GetError() | 127 get_error = _GetError() |