<commit_before>from django.shortcuts import get_object_or_404
from django.template import Context, loader as template_loader
from django.conf import settings
from django.core.context_processors import csrf

from rest_framework import decorators, permissions
from rest_framework.renderers import JSONPRenderer, JSONRenderer, BrowsableAPIRenderer
from rest_framework.response import Response

from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Version
from readthedocs.donate.models import SupporterPromo
from readthedocs.projects.models import Project
from projects.version_handling import highest_version
from projects.version_handling import parse_version_failsafe


def get_version_compare_data(project, base_version=None):
    highest_version_obj, highest_version_comparable = highest_version(
        project.versions.filter(active=True))
    ret_val = {
        'project': unicode(highest_version_obj),
        'version': unicode(highest_version_comparable),
        'is_highest': True,
    }
    if highest_version_obj:
        ret_val['url'] = highest_version_obj.get_absolute_url()
        ret_val['slug'] = highest_version_obj.slug,
    if base_version and base_version.slug != LATEST:
        try:
            base_version_comparable = parse_version_failsafe(
                base_version.verbose_name)
            if base_version_comparable:
                # This is only place where is_highest can get set. All error<commit_msg>Prefix imports with readthedocs<commit_after>from django.shortcuts import get_object_or_404
from django.template import Context, loader as template_loader
from django.conf import settings
from django.core.context_processors import csrf

from rest_framework import decorators, permissions
from rest_framework.renderers import JSONPRenderer, JSONRenderer, BrowsableAPIRenderer
from rest_framework.response import Response

from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Version
from readthedocs.donate.models import SupporterPromo
from readthedocs.projects.models import Project
from readthedocs.projects.version_handling import highest_version
from readthedocs.projects.version_handling import parse_version_failsafe


def get_version_compare_data(project, base_version=None):
    highest_version_obj, highest_version_comparable = highest_version(
        project.versions.filter(active=True))
    ret_val = {
        'project': unicode(highest_version_obj),
        'version': unicode(highest_version_comparable),
        'is_highest': True,
    }
    if highest_version_obj:
        ret_val['url'] = highest_version_obj.get_absolute_url()
        ret_val['slug'] = highest_version_obj.slug,
    if base_version and base_version.slug != LATEST:
        try:
            base_version_comparable = parse_version_failsafe(
                base_version.verbose_name)
            if base_version_comparable:
                # This is only place where is_highest can get set. All error
{'fraction_non_alphanumeric': 0.05744822979291917, 'fraction_numerical': 0.002004008016032064, 'mean_word_length': 4.525830258302583, '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': '5551535', 'n_tokens_mistral': 866, 'n_tokens_neox': 822, 'n_words': 202}