<commit_before>from logging.handlers import SMTPHandler, RotatingFileHandler
import os

from flask import Flask, request, render_template
from flask import escape

import logging
import pprint
from markupsafe import Markup

import re


def relativize_paths(value, path):
    """
    THIS IS A FILTER.
    It should be moved somewhere else.
    It prepends the specified path to all src paths in the specified blocks so that the path can be relative
    to the static directory of the App (or to an arbitrary directory).
    :return:
    """
    expr = """src=["'](.+?)["']"""

    def repl(matchobj):
        """
        Function to be called in every match for replacing.
        :return: Replaced URI.
        """
        oldurl = matchobj.group(1)
        newurl = os.path.join(path, oldurl)
        return newurl

    newvalue = re.sub(expr, repl, value)

    return Markup(newvalue)



app = Flask(__name__)
app.config["SECRET_KEY"] = os.urandom(32)
app.config['SESSION_COOKIE_NAME'] = 'appcompsession'
app.config['SQLALCHEMY_NATIVE_UNICODE'] = True
app.config['SQLALCHEMY_POOL_RECYCLE'] = 3600<commit_msg>Fixed issue with the relativize_paths system<commit_after>from logging.handlers import SMTPHandler, RotatingFileHandler
import os

from flask import Flask, request, render_template
from flask import escape

import logging
import pprint
from markupsafe import Markup

import re


def relativize_paths(value, path):
    """
    THIS IS A FILTER.
    It should be moved somewhere else.
    It prepends the specified path to all src paths in the specified blocks so that the path can be relative
    to the static directory of the App (or to an arbitrary directory).
    :return:
    """
    expr = """src=["'](.+?)["']"""

    def repl(matchobj):
        """
        Function to be called in every match for replacing.
        :return: Replaced URI.
        """
        oldurl = matchobj.group(1)
        newurl = 'src="%s"' % os.path.join(path, oldurl)
        return newurl

    newvalue = re.sub(expr, repl, value)

    return Markup(newvalue)



app = Flask(__name__)
app.config["SECRET_KEY"] = os.urandom(32)
app.config['SESSION_COOKIE_NAME'] = 'appcompsession'
app.config['SQLALCHEMY_NATIVE_UNICODE'] = True
app.config['SQLALCHEMY_POOL_RECYCLE'] = 3600
{'fraction_non_alphanumeric': 0.09841129744042365, 'fraction_numerical': 0.00617828773168579, 'mean_word_length': 3.4450980392156865, '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': '5185768', 'n_tokens_mistral': 729, 'n_tokens_neox': 687, 'n_words': 229}