<commit_before>from ..models import Settings
from django.http import HttpRequest
import json

NAV_BAR_SETTINGS_KEY: str = "frontpage.ui.navbar.content"


def process_link(position: int, item):
    return '<a href="' + item.get('href') + '">' + item.get('text') + '</a>'


def render_nav_bar(request: HttpRequest):
    try:
        feature_line: str = Settings.objects.find(SName=NAV_BAR_SETTINGS_KEY).property
        parts = json.loads(feature_line)
        a = '<div class="nav">'
        pos = -1
        for item in parts:
            pos += 1
            if str(item.get('type')) == "link":
                a += process_link(pos, item)
        a += '</div>'
        return a
    except:
        return "<h3>An error was thrown resulting in the incapability to display the nav bar</h3>"<commit_msg>Fixed last mistake<commit_after>from ..models import Settings
from django.http import HttpRequest
import json

NAV_BAR_SETTINGS_KEY: str = "frontpage.ui.navbar.content"


def process_link(position: int, item):
    return '<a href="' + item.get('href') + '">' + item.get('text') + '</a>'


def render_nav_bar(request: HttpRequest):
    try:
        feature_line: str = Settings.objects.get(SName=NAV_BAR_SETTINGS_KEY).property
        parts = json.loads(feature_line)
        a = '<div class="nav">'
        pos = -1
        for item in parts:
            pos += 1
            if str(item.get('type')) == "link":
                a += process_link(pos, item)
        a += '</div>'
        return a
    except Exception as e:
        return "<h3>An error was thrown resulting in the incapability to display the nav bar:</h3>" + str(e)
{'fraction_non_alphanumeric': 0.13472137170851195, 'fraction_numerical': 0.004898958971218616, 'mean_word_length': 2.663677130044843, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, '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': '5266789', 'n_tokens_mistral': 515, 'n_tokens_neox': 504, 'n_words': 141}