<commit_before>from datetime import datetime
import json
import time

from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy.sql import not_


with open('locales/pokemon.en.json') as f:
    pokemon_names = json.load(f)


try:
    import config
    DB_ENGINE = config.DB_ENGINE
except ImportError, AttributeError:
    DB_ENGINE = 'sqlite:///db.sqlite'


def get_engine():
    return create_engine(DB_ENGINE)

Base = declarative_base()


class SightingCache(object):
    def __init__(self):
        self.store = {}

    @staticmethod
    def _make_key(sighting):
        return (
            sighting.pokemon_id,
            sighting.spawn_id,
            sighting.normalized_timestamp,
            sighting.lat,
            sighting.lon,
        )

    def add(self, sighting):
        self.store[self._make_key(sighting)] = True

    def __contains__(self, sighting):
        obj = self.store.get(self._make_key(sighting))
        if not obj:
            return False
        timestamp_in_range = (
            obj.expire_timestamp > sighting.expire_timestamp - 5 and
            obj.expire_timestamp < sighting.expire_timestamp + 5
        )
        return timestamp_in_range<commit_msg>Okay, store timestamp instead of bool<commit_after>from datetime import datetime
import json
import time

from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy.sql import not_


with open('locales/pokemon.en.json') as f:
    pokemon_names = json.load(f)


try:
    import config
    DB_ENGINE = config.DB_ENGINE
except ImportError, AttributeError:
    DB_ENGINE = 'sqlite:///db.sqlite'


def get_engine():
    return create_engine(DB_ENGINE)

Base = declarative_base()


class SightingCache(object):
    def __init__(self):
        self.store = {}

    @staticmethod
    def _make_key(sighting):
        return (
            sighting.pokemon_id,
            sighting.spawn_id,
            sighting.normalized_timestamp,
            sighting.lat,
            sighting.lon,
        )

    def add(self, sighting):
        self.store[self._make_key(sighting)] = sighting.expire_timestamp

    def __contains__(self, sighting):
        expire_timestamp = self.store.get(self._make_key(sighting))
        if not expire_timestamp:
            return False
        timestamp_in_range = (
            expire_timestamp > sighting.expire_timestamp - 5 and
            expire_timestamp < sighting.expire_timestamp + 5
        )
        return timestamp_in_range
{'fraction_non_alphanumeric': 0.075707460492466, 'fraction_numerical': 0.001470047776552738, 'mean_word_length': 2.7858136300417247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5223563', 'n_tokens_mistral': 853, 'n_tokens_neox': 809, 'n_words': 186}