def range_usage_text(request):
    start = request.GET.get('start', None)
    end = request.GET.get('end', None)
    format = request.GET.get('format', 'human_readable')
    if not (start and end):
        return HttpResponse(json.dumps({
            'success': False,
            'error_messages': 'Provide a start and end'}))

    get_objects = request.GET.get('get_objects', False)
    if start.find(':') > -1:
        ip_type = '6'
    else:
        ip_type = '4'
    try:
        usage_data = range_usage(start, end, ip_type, get_objects)
    except (__HOLE__, ipaddr.AddressValueError), e:
        return HttpResponse(
            json.dumps({
                'error_messages': str(e),
                'success': False
            }))

    if format == 'human_readable':
        usage_data['free_ranges'] = map(lambda x: (int_to_ip(x[0], ip_type),
                                        int_to_ip(x[1], ip_type)),
                                        usage_data['free_ranges'])

    usage_data['success'] = True
    return HttpResponse(json.dumps(usage_data))
dataset/ETHPy150Open rtucker-mozilla/mozilla_inventory/core/range/views.py/range_usage_text