@register.inclusion_tag("resources/stats_bar_simple.html")
def stats_bar_simple(stat, width=100):
    """
    Create a HTML bar to present the statistics of an object.

    The object should have attributes trans_percent/untrans_percent.
    Accepts an optional parameter to specify the width of the total bar.

    We do a bit of calculations ourselfs here to reduce the pressure on
    the database.
    """
    total = stat.total
    trans = stat.translated

    try:
        trans_percent = (trans * 100 / total)
    except ZeroDivisionError:
        trans_percent = 100

    untrans_percent = 100 - trans_percent
    untrans = total - trans

    return {'untrans_percent': untrans_percent,
            'trans_percent': trans_percent,
            'untrans': untrans,
            'trans': trans,
            'pos': StatBarsPositions([('trans', trans_percent),
                                      ('untrans', untrans_percent)], width),
            'width':width}
dataset/ETHPy150Open rvanlaar/easy-transifex/src/transifex/transifex/resources/templatetags/statistics_resources.py/stats_bar_simple/original