<commit_before>from django.conf import settings
from django.db import models
from django.utils.encoding import smart_str
from geopy import geocoders



class Address(models.Model):
    address = models.CharField(max_length=255, db_index=True)
    computed_address = models.CharField(max_length=255, null=True, blank=True)
    latitude = models.FloatField(null=True, blank=True)
    longitude = models.FloatField(null=True, blank=True)
    geocode_error = models.BooleanField(default=False)

    def fill_geocode_data(self):
        if not self.address:
            self.geocode_error = True
            return
        try:
            if hasattr(settings, "EASY_MAPS_GOOGLE_KEY"):
                g = geocoders.Google(settings.EASY_MAPS_GOOGLE_KEY)
            else:
                g = geocoders.Google(resource='maps')
            address = smart_str(self.address)
            self.computed_address, (self.latitude, self.longitude,) = g.geocode(address)
            self.geocode_error = False
        except (UnboundLocalError, ValueError,):
            self.geocode_error = True

    def save(self, *args, **kwargs):
        # fill geocode data if it is unknown
        if (self.longitude is None) or (self.latitude is None):
            self.fill_geocode_data()
        super(Address, self).save(*args, **kwargs)

    def __unicode__(self):
        return self.address
<commit_msg>Adding Google API key to help when you get blocked<commit_after>from django.conf import settings
from django.db import models
from django.utils.encoding import smart_str
from geopy import geocoders



class Address(models.Model):
    address = models.CharField(max_length=255, db_index=True)
    computed_address = models.CharField(max_length=255, null=True, blank=True)
    latitude = models.FloatField(null=True, blank=True)
    longitude = models.FloatField(null=True, blank=True)
    geocode_error = models.BooleanField(default=False)

    def fill_geocode_data(self):
        if not self.address:
            self.geocode_error = True
            return
        try:
            if hasattr(settings, "EASY_MAPS_GOOGLE_KEY") and settings.EASY_MAPS_GOOGLE_KEY:
                g = geocoders.Google(settings.EASY_MAPS_GOOGLE_KEY)
            else:
                g = geocoders.Google(resource='maps')
            address = smart_str(self.address)
            self.computed_address, (self.latitude, self.longitude,) = g.geocode(address)
            self.geocode_error = False
        except (UnboundLocalError, ValueError,):
            self.geocode_error = True

    def save(self, *args, **kwargs):
        # fill geocode data if it is unknown
        if (self.longitude is None) or (self.latitude is None):
            self.fill_geocode_data()
        super(Address, self).save(*args, **kwargs)

    def __unicode__(self):
        return self.address

{'fraction_non_alphanumeric': 0.09257303766279479, 'fraction_numerical': 0.004223864836325237, 'mean_word_length': 2.835357624831309, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4696533', 'n_tokens_mistral': 887, 'n_tokens_neox': 859, 'n_words': 191}