<commit_before>script_template = """from retriever.lib.templates import BasicTextTemplate
from retriever.lib.models import Table, Cleanup, correct_invalid_value

VERSION = '0.5'

SCRIPT = BasicTextTemplate(%s)"""

TABLE_KEYS = ['contains_pk', 'header_rows', 'delimiter']


def compile_script(script_file):
    definition = open(script_file + ".script", 'rb')
    
    values = {}
    urls = {}
    tables = {}
    last_table = ""
    replace = []
    columns = []
    
    for line in [line.strip() for line in definition]:
        if line and ':' in line and not line[0] == '#':
            split_line = [a.strip() for a in line.split(":")]
            key = split_line[0].lower()
            value = ':'.join(split_line[1:])
            if key == "table":
                table_name = value.split(',')[0].strip()
                last_table = table_name
                table_url = ','.join(value.split(',')[1:]).strip()
                urls[table_name] = table_url
                if replace:
                    try:
                        tables[last_table]
                    except:
                        tables[table_name] = {'replace_columns': str(replace)}
            elif key == "nulls":
                if last_table:
                    nulls = [v if v != "EMPTY" else None for v in [v.strip() for v in value.split(',')]]
                    try:
                        tables[last_table]
                    except KeyError:
                        if replace:
                            tables[last_table] = {'replace_columns': str(replace)}
                        else:
                            tables[last_table] = {}
                    tables[last_table]['cleanup'] = "Cleanup(correct_invalid_value, nulls=" + str(nulls) + ")"
            elif key == "replace":
                replace = [(v.split(',')[0].strip(), v.split(',')[1].strip())
                           for v in [v.strip() for v in value.split(';')]]
            elif key == "tags":<commit_msg>Removing unnecessary columns variable.<commit_after>script_template = """from retriever.lib.templates import BasicTextTemplate
from retriever.lib.models import Table, Cleanup, correct_invalid_value

VERSION = '0.5'

SCRIPT = BasicTextTemplate(%s)"""

TABLE_KEYS = ['contains_pk', 'header_rows', 'delimiter']


def compile_script(script_file):
    definition = open(script_file + ".script", 'rb')
    
    values = {}
    urls = {}
    tables = {}
    last_table = ""
    replace = []
    
    for line in [line.strip() for line in definition]:
        if line and ':' in line and not line[0] == '#':
            split_line = [a.strip() for a in line.split(":")]
            key = split_line[0].lower()
            value = ':'.join(split_line[1:])
            if key == "table":
                table_name = value.split(',')[0].strip()
                last_table = table_name
                table_url = ','.join(value.split(',')[1:]).strip()
                urls[table_name] = table_url
                if replace:
                    try:
                        tables[last_table]
                    except:
                        tables[table_name] = {'replace_columns': str(replace)}
            elif key == "nulls":
                if last_table:
                    nulls = [v if v != "EMPTY" else None for v in [v.strip() for v in value.split(',')]]
                    try:
                        tables[last_table]
                    except KeyError:
                        if replace:
                            tables[last_table] = {'replace_columns': str(replace)}
                        else:
                            tables[last_table] = {}
                    tables[last_table]['cleanup'] = "Cleanup(correct_invalid_value, nulls=" + str(nulls) + ")"
            elif key == "replace":
                replace = [(v.split(',')[0].strip(), v.split(',')[1].strip())
                           for v in [v.strip() for v in value.split(';')]]
            elif key == "tags":
{'fraction_non_alphanumeric': 0.13962832747363135, 'fraction_numerical': 0.0045203415369161224, 'mean_word_length': 1.5964797913950457, 'pattern_counts': {'":': 10, '<': 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': '3571507', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1087, 'n_words': 257}