##// END OF EJS Templates
helpers: remove deprecated fancy_file_stats that is not used anymore.
marcink -
r1583:73b23dff default
parent child Browse files
Show More
@@ -1549,99 +1549,6 b' def format_byte_size_binary(file_size):'
1549 return formatted_size
1549 return formatted_size
1550
1550
1551
1551
1552 def fancy_file_stats(stats):
1553 """
1554 Displays a fancy two colored bar for number of added/deleted
1555 lines of code on file
1556
1557 :param stats: two element list of added/deleted lines of code
1558 """
1559 from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
1560 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
1561
1562 def cgen(l_type, a_v, d_v):
1563 mapping = {'tr': 'top-right-rounded-corner-mid',
1564 'tl': 'top-left-rounded-corner-mid',
1565 'br': 'bottom-right-rounded-corner-mid',
1566 'bl': 'bottom-left-rounded-corner-mid'}
1567 map_getter = lambda x: mapping[x]
1568
1569 if l_type == 'a' and d_v:
1570 #case when added and deleted are present
1571 return ' '.join(map(map_getter, ['tl', 'bl']))
1572
1573 if l_type == 'a' and not d_v:
1574 return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
1575
1576 if l_type == 'd' and a_v:
1577 return ' '.join(map(map_getter, ['tr', 'br']))
1578
1579 if l_type == 'd' and not a_v:
1580 return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
1581
1582 a, d = stats['added'], stats['deleted']
1583 width = 100
1584
1585 if stats['binary']: # binary operations like chmod/rename etc
1586 lbl = []
1587 bin_op = 0 # undefined
1588
1589 # prefix with bin for binary files
1590 if BIN_FILENODE in stats['ops']:
1591 lbl += ['bin']
1592
1593 if NEW_FILENODE in stats['ops']:
1594 lbl += [_('new file')]
1595 bin_op = NEW_FILENODE
1596 elif MOD_FILENODE in stats['ops']:
1597 lbl += [_('mod')]
1598 bin_op = MOD_FILENODE
1599 elif DEL_FILENODE in stats['ops']:
1600 lbl += [_('del')]
1601 bin_op = DEL_FILENODE
1602 elif RENAMED_FILENODE in stats['ops']:
1603 lbl += [_('rename')]
1604 bin_op = RENAMED_FILENODE
1605
1606 # chmod can go with other operations, so we add a + to lbl if needed
1607 if CHMOD_FILENODE in stats['ops']:
1608 lbl += [_('chmod')]
1609 if bin_op == 0:
1610 bin_op = CHMOD_FILENODE
1611
1612 lbl = '+'.join(lbl)
1613 b_a = '<div class="bin bin%s %s" style="width:100%%">%s</div>' \
1614 % (bin_op, cgen('a', a_v='', d_v=0), lbl)
1615 b_d = '<div class="bin bin1" style="width:0%%"></div>'
1616 return literal('<div style="width:%spx">%s%s</div>' % (width, b_a, b_d))
1617
1618 t = stats['added'] + stats['deleted']
1619 unit = float(width) / (t or 1)
1620
1621 # needs > 9% of width to be visible or 0 to be hidden
1622 a_p = max(9, unit * a) if a > 0 else 0
1623 d_p = max(9, unit * d) if d > 0 else 0
1624 p_sum = a_p + d_p
1625
1626 if p_sum > width:
1627 #adjust the percentage to be == 100% since we adjusted to 9
1628 if a_p > d_p:
1629 a_p = a_p - (p_sum - width)
1630 else:
1631 d_p = d_p - (p_sum - width)
1632
1633 a_v = a if a > 0 else ''
1634 d_v = d if d > 0 else ''
1635
1636 d_a = '<div class="added %s" style="width:%s%%">%s</div>' % (
1637 cgen('a', a_v, d_v), a_p, a_v
1638 )
1639 d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % (
1640 cgen('d', a_v, d_v), d_p, d_v
1641 )
1642 return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d))
1643
1644
1645 def urlify_text(text_, safe=True):
1552 def urlify_text(text_, safe=True):
1646 """
1553 """
1647 Extrac urls from text and make html links out of them
1554 Extrac urls from text and make html links out of them
General Comments 0
You need to be logged in to leave comments. Login now