# Path: amon/utils/filesize.py
# def size(bytes, system=alternative):
#     """Human-readable file size.
# 
#     Using the traditional system, where a factor of 1024 is used::
#     
#     >>> size(10)
#     '10B'
#     >>> size(100)
#     '100B'
#     >>> size(1000)
#     '1000B'
#     >>> size(2000)
#     '1K'
#     >>> size(10000)
#     '9K'
#     >>> size(20000)
#     '19K'
#     >>> size(100000)
#     '97K'
#     >>> size(200000)
#     '195K'
#     >>> size(1000000)
#     '976K'
#     >>> size(2000000)
#     '1M'
#     
#     Using the SI system, with a factor 1000::
# 
#     >>> size(10, system=si)
#     '10B'
#     >>> size(100, system=si)
#     '100B'
#     >>> size(1000, system=si)
#     '1K'
#     >>> size(2000, system=si)
#     '2K'
#     >>> size(10000, system=si)
#     '10K'
#     >>> size(20000, system=si)
#     '20K'
#     >>> size(100000, system=si)
#     '100K'
#     >>> size(200000, system=si)
#     '200K'
#     >>> size(1000000, system=si)
#     '1M'
#     >>> size(2000000, system=si)
#     '2M'
#     
#     """
#     for factor, suffix in system:
#         if bytes >= factor:
#             break
#     amount = int(bytes/factor)
#     if isinstance(suffix, tuple):
#         singular, multiple = suffix
#         if amount == 1:
#             suffix = singular
#         else:
#             suffix = multiple
#     return str(amount) + suffix


from django import template
from amon.utils.filesize import size
    
    return mb


@register.filter
def seconds_to_minutes(value):
    minutes = value/60


    return minutes


# Used in alerts/all
@register.filter
def metric_type_value(value, metric):
    result = ""
    metric = metric.lower()

    if metric == 'memory':
        result = 'MB'
    elif metric == 'down':
        result = 'Down between'
    else:
        result = value 

    return result

@register.filter
def bytes_to_mb(value):


# Path: amon/utils/filesize.py
# def size(bytes, system=alternative):
#     """Human-readable file size.
# 
#     Using the traditional system, where a factor of 1024 is used::
#     
#     >>> size(10)
#     '10B'
#     >>> size(100)
#     '100B'
#     >>> size(1000)
#     '1000B'
#     >>> size(2000)
#     '1K'
#     >>> size(10000)
#     '9K'
#     >>> size(20000)
#     '19K'
#     >>> size(100000)
#     '97K'
#     >>> size(200000)
#     '195K'
#     >>> size(1000000)
#     '976K'
#     >>> size(2000000)
#     '1M'
#     
#     Using the SI system, with a factor 1000::
# 
#     >>> size(10, system=si)
#     '10B'
#     >>> size(100, system=si)
#     '100B'
#     >>> size(1000, system=si)
#     '1K'
#     >>> size(2000, system=si)
#     '2K'
#     >>> size(10000, system=si)
#     '10K'
#     >>> size(20000, system=si)
#     '20K'
#     >>> size(100000, system=si)
#     '100K'
#     >>> size(200000, system=si)
#     '200K'
#     >>> size(1000000, system=si)
#     '1M'
#     >>> size(2000000, system=si)
#     '2M'
#     
#     """
#     for factor, suffix in system:
#         if bytes >= factor:
#             break
#     amount = int(bytes/factor)
#     if isinstance(suffix, tuple):
#         singular, multiple = suffix
#         if amount == 1:
#             suffix = singular
#         else:
#             suffix = multiple
#     return str(amount) + suffix


# Path: amon/templatetags/metrics.py
from django import template
from amon.utils.filesize import size

    
    return mb


@register.filter
def seconds_to_minutes(value):
    minutes = value/60


    return minutes


# Used in alerts/all
@register.filter
def metric_type_value(value, metric):
    result = ""
    metric = metric.lower()

    if metric == 'memory':
        result = 'MB'
    elif metric == 'down':
        result = 'Down between'
    else:
        result = value 

    return result

@register.filter
def bytes_to_mb(value):


    return size(value)