helpers: remove deprecated fancy_file_stats that is not used anymore.
This commit is contained in:
parent
feb25a9cb8
commit
f3033e7610
1 changed files with 0 additions and 93 deletions
|
|
@ -1549,99 +1549,6 @@ def format_byte_size_binary(file_size):
|
|||
return formatted_size
|
||||
|
||||
|
||||
def fancy_file_stats(stats):
|
||||
"""
|
||||
Displays a fancy two colored bar for number of added/deleted
|
||||
lines of code on file
|
||||
|
||||
:param stats: two element list of added/deleted lines of code
|
||||
"""
|
||||
from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
|
||||
MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
|
||||
|
||||
def cgen(l_type, a_v, d_v):
|
||||
mapping = {'tr': 'top-right-rounded-corner-mid',
|
||||
'tl': 'top-left-rounded-corner-mid',
|
||||
'br': 'bottom-right-rounded-corner-mid',
|
||||
'bl': 'bottom-left-rounded-corner-mid'}
|
||||
map_getter = lambda x: mapping[x]
|
||||
|
||||
if l_type == 'a' and d_v:
|
||||
#case when added and deleted are present
|
||||
return ' '.join(map(map_getter, ['tl', 'bl']))
|
||||
|
||||
if l_type == 'a' and not d_v:
|
||||
return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
|
||||
|
||||
if l_type == 'd' and a_v:
|
||||
return ' '.join(map(map_getter, ['tr', 'br']))
|
||||
|
||||
if l_type == 'd' and not a_v:
|
||||
return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
|
||||
|
||||
a, d = stats['added'], stats['deleted']
|
||||
width = 100
|
||||
|
||||
if stats['binary']: # binary operations like chmod/rename etc
|
||||
lbl = []
|
||||
bin_op = 0 # undefined
|
||||
|
||||
# prefix with bin for binary files
|
||||
if BIN_FILENODE in stats['ops']:
|
||||
lbl += ['bin']
|
||||
|
||||
if NEW_FILENODE in stats['ops']:
|
||||
lbl += [_('new file')]
|
||||
bin_op = NEW_FILENODE
|
||||
elif MOD_FILENODE in stats['ops']:
|
||||
lbl += [_('mod')]
|
||||
bin_op = MOD_FILENODE
|
||||
elif DEL_FILENODE in stats['ops']:
|
||||
lbl += [_('del')]
|
||||
bin_op = DEL_FILENODE
|
||||
elif RENAMED_FILENODE in stats['ops']:
|
||||
lbl += [_('rename')]
|
||||
bin_op = RENAMED_FILENODE
|
||||
|
||||
# chmod can go with other operations, so we add a + to lbl if needed
|
||||
if CHMOD_FILENODE in stats['ops']:
|
||||
lbl += [_('chmod')]
|
||||
if bin_op == 0:
|
||||
bin_op = CHMOD_FILENODE
|
||||
|
||||
lbl = '+'.join(lbl)
|
||||
b_a = '<div class="bin bin%s %s" style="width:100%%">%s</div>' \
|
||||
% (bin_op, cgen('a', a_v='', d_v=0), lbl)
|
||||
b_d = '<div class="bin bin1" style="width:0%%"></div>'
|
||||
return literal('<div style="width:%spx">%s%s</div>' % (width, b_a, b_d))
|
||||
|
||||
t = stats['added'] + stats['deleted']
|
||||
unit = float(width) / (t or 1)
|
||||
|
||||
# needs > 9% of width to be visible or 0 to be hidden
|
||||
a_p = max(9, unit * a) if a > 0 else 0
|
||||
d_p = max(9, unit * d) if d > 0 else 0
|
||||
p_sum = a_p + d_p
|
||||
|
||||
if p_sum > width:
|
||||
#adjust the percentage to be == 100% since we adjusted to 9
|
||||
if a_p > d_p:
|
||||
a_p = a_p - (p_sum - width)
|
||||
else:
|
||||
d_p = d_p - (p_sum - width)
|
||||
|
||||
a_v = a if a > 0 else ''
|
||||
d_v = d if d > 0 else ''
|
||||
|
||||
d_a = '<div class="added %s" style="width:%s%%">%s</div>' % (
|
||||
cgen('a', a_v, d_v), a_p, a_v
|
||||
)
|
||||
d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % (
|
||||
cgen('d', a_v, d_v), d_p, d_v
|
||||
)
|
||||
return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d))
|
||||
|
||||
|
||||
def urlify_text(text_, safe=True):
|
||||
"""
|
||||
Extrac urls from text and make html links out of them
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue