<commit_before>from django.http import Http404
from django.shortcuts import get_object_or_404
from django.core.urlresolvers import reverse
from cms import settings
from cms.models import Page
from cms.utils import auto_render, get_template_from_request, get_language_from_request
from django.db.models.query_utils import Q
from cms.appresolver import applications_page_check
from django.contrib.sites.models import Site

def _get_current_page(path, lang):
    """Helper for getting current page from path depending on language
    
    returns: Page or None
    """
    try:
        return Page.objects.published().filter( 
            Q(title_set__path=path[:-1], title_set__language=lang)).distinct().select_related()[0]
    except IndexError:
        return None

def details(request, page_id=None, slug=None, template_name=settings.CMS_TEMPLATES[0][0], no404=False):
    lang = get_language_from_request(request)
    site = Site.objects.get_current()
    pages = Page.objects.root().order_by("tree_id")
    current_page, response = None, None
    if pages:
        if page_id:
            current_page = get_object_or_404(Page.objects.published(site), pk=page_id)
        elif slug != None:
            if slug == "":
                current_page = pages[0]<commit_msg>root page needs to be published now<commit_after>from django.http import Http404
from django.shortcuts import get_object_or_404
from django.core.urlresolvers import reverse
from cms import settings
from cms.models import Page
from cms.utils import auto_render, get_template_from_request, get_language_from_request
from django.db.models.query_utils import Q
from cms.appresolver import applications_page_check
from django.contrib.sites.models import Site

def _get_current_page(path, lang):
    """Helper for getting current page from path depending on language
    
    returns: Page or None
    """
    try:
        return Page.objects.published().filter( 
            Q(title_set__path=path[:-1], title_set__language=lang)).distinct().select_related()[0]
    except IndexError:
        return None

def details(request, page_id=None, slug=None, template_name=settings.CMS_TEMPLATES[0][0], no404=False):
    lang = get_language_from_request(request)
    site = Site.objects.get_current()
    pages = Page.objects.published().root().order_by("tree_id")
    current_page, response = None, None
    if pages:
        if page_id:
            current_page = get_object_or_404(Page.objects.published(site), pk=page_id)
        elif slug != None:
            if slug == "":
                current_page = pages[0]
{'fraction_non_alphanumeric': 0.08953488372093023, 'fraction_numerical': 0.01317829457364341, 'mean_word_length': 3.851503759398496, 'pattern_counts': {'":': 2, '<': 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': '3652705', 'n_tokens_mistral': 780, 'n_tokens_neox': 753, 'n_words': 193}