def get_contest(self, raw_result):
        """
        Returns the Contest model instance for a given RawResult.

        Caches the result in memory to reduce the number of calls to the
        datastore.
        """
        key = "%s-%s" % (raw_result.election_id, raw_result.contest_slug)

        try:
            #print self._contest_cache[key]
            return self._contest_cache[key]
        except KeyError:
            #raise
            fields = self.get_contest_fields(raw_result)
            #print fields
            #quit(fields['source'])
            fields.pop('source')
            try:
                #contest = Contest.objects.get(**fields)
                try:
                    contest = Contest.objects.filter(**fields)[0]
                except __HOLE__:
                    contest = Contest.objects.get(**fields)
                #print contest
                #quit("uuuuuuuuuuuu")
            except Exception:
                print fields
                print "\n"
                raise
            self._contest_cache[key] = contest
            return contest
dataset/ETHPy150Open openelections/openelections-core/openelex/us/wa/transform/__init__.py/BaseTransform.get_contest