<commit_before>#! -*- coding: utf-8 -*-
import urllib2
import urllib
import json

from django.core.urlresolvers import reverse
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.utils import simplejson
from store_locator.models import Location

def get_lat_long(request):
    if not request.GET.get('q'):
        return HttpResponse('')
    query = request.GET.get('q')
    if query == "L'Aquila,italy":
        query = "LAquila,italy"
    if query == u"Trentino-Alto Adige/Südtirol,italy":
        query = "Trentino-Alto Adige"
    if query == u"monza e della brianza,italy":
        query = "Monza-Brainza,italy"
    url="http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false" % query
    response = urllib2.urlopen(url)
    jsongeocode = simplejson.loads(response.read())
    return HttpResponse(simplejson.dumps(jsongeocode), mimetype="application/json")

def get_near_locations(request):
    try:
        latitude = float(request.GET.get('lat'))
        longitude = float(request.GET.get('long'))
        distance = int(request.GET.get('distance', 0))
        location_type = request.GET.get('location_type', '0')
    except:
        return HttpResponse('[]')
    locations = Location.objects.near(latitude, longitude, distance)
    if location_type:
        locations = [l for l in locations if location_type in [str(t[0]) for t in l.location_types.values_list('id')]]<commit_msg>fix regione<commit_after>#! -*- coding: utf-8 -*-
import urllib2
import urllib
import json

from django.core.urlresolvers import reverse
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.utils import simplejson
from store_locator.models import Location

def get_lat_long(request):
    if not request.GET.get('q'):
        return HttpResponse('')
    query = request.GET.get('q')
    if query == "L'Aquila,italy":
        query = "LAquila,italy"
    if query == u"<NAME>":
        query = "friuli-venezia-giulia"
    if query == u"Trentino-Alto Adige/Südtirol,italy":
        query = "Trentino-Alto Adige"
    if query == u"monza e della brianza,italy":
        query = "Monza-Brainza,italy"
    if query == u"monza e della brianza,italy":
        query = "Monza-Brainza,italy"
    url="http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false" % query
    response = urllib2.urlopen(url)
    jsongeocode = simplejson.loads(response.read())
    return HttpResponse(simplejson.dumps(jsongeocode), mimetype="application/json")

def get_near_locations(request):
    try:
        latitude = float(request.GET.get('lat'))
        longitude = float(request.GET.get('long'))
        distance = int(request.GET.get('distance', 0))
        location_type = request.GET.get('location_type', '0')
    except:
        return HttpResponse('[]')
    locations = Location.objects.near(latitude, longitude, distance)
    if location_type:
        locations = [l for l in locations if location_type in [str(t[0]) for t in l.location_types.values_list('id')]]
{'fraction_non_alphanumeric': 0.12380364309972214, 'fraction_numerical': 0.007409694350108058, 'mean_word_length': 3.909090909090909, 'pattern_counts': {'":': 8, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6850663', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1037, 'n_words': 233}