<commit_before>import web
import yaml


#from .paths import PREFIX

def wmt_conf(**kwds):
    prefix = kwds.default('prefix', PREFIX)
    database_dir = kwds.default('database_dir', os.path.join(prefix, 'db'))

    from string import Template
    contents = Template("""
wmt:
    database_dir: ${prefix}/db
    data_dir: ${prefix}/data
    """)
    return contents.substitute(prefix=prefix)


def load_wmt_conf(file):
    with open(file, 'r') as conf_file:
        conf = yaml.load(conf_file.read())
    return conf


def read_site_conf(site_prefix):
    from ConfigParser import RawConfigParser

    conf_file_path = os.path.join(site_prefix, 'conf', 'wmt.ini')
    conf = RawConfigParser()

    #with open(conf_file_path, 'r') as conf_file:
    #    conf = yaml.load(conf_file.read())

    return conf


def read_config_file(path_to_file):
    from ConfigParser import RawConfigParser
    from passlib.context import CryptContext

    config = RawConfigParser()
    config.read(path_to_file)

    site = dict(config.items('wmt'))
    site['pw'] = CryptContext.from_path(path_to_file, section='passlib')
    return site


def write_config_file(path_to_file, items):
    from ConfigParser import RawConfigParser
    config = RawConfigParser()
    for item in items:
        conf.set('wmt', *items)
    config.write(path_to_file)


def read_site_config_file(*args):
    import os
    try:
        prefix = args[0]
    except IndexError:
        try:
            prefix = os.environ['WMT_PREFIX']
        except KeyError:
            raise

    os.environ['WMT_PREFIX'] = os.path.abspath(prefix)
    path = os.path.join(os.environ['WMT_PREFIX'], 'conf', 'wmt.ini')
    return read_config_file(path)
<commit_msg>Removed unused functions.<commit_after>import web


def read_config_file(path_to_file):
    from ConfigParser import RawConfigParser
    from passlib.context import CryptContext

    config = RawConfigParser()
    config.read(path_to_file)

    site = dict(config.items('wmt'))
    site['pw'] = CryptContext.from_path(path_to_file, section='passlib')
    return site


def read_site_config_file(*args):
    import os
    try:
        prefix = args[0]
    except IndexError:
        try:
            prefix = os.environ['WMT_PREFIX']
        except KeyError:
            raise

    os.environ['WMT_PREFIX'] = os.path.abspath(prefix)
    path = os.path.join(os.environ['WMT_PREFIX'], 'conf', 'wmt.ini')
    return read_config_file(path)

{'fraction_non_alphanumeric': 0.11374795417348608, 'fraction_numerical': 0.0008183306055646482, 'mean_word_length': 3.358288770053476, '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': '6370669', 'n_tokens_mistral': 814, 'n_tokens_neox': 790, 'n_words': 168}