<commit_before>
import re
import numpy as np

# Code in str2bool and readini pulled from github.com/bsmithyman/pygeo/pygeo/fullpy.py
# Original code is licensed LGPL; I am explicitly re-licensing this under the umbrella
# of the windtunnel MIT license. -- <NAME>

def str2bool(v):
    '''
    Converts certain string values to a boolean.
    '''

    return v.lower() in ("yes", "true", "t", "1")

def readini (infile):
    '''
    Reads (2.5-D) omega ini file of a given filename.
    '''

    f = open(infile, 'r')
    lines = f.readlines()
    f.close()

    settingsdict = {}

    lsplit = lines[1].strip().split()
    settingsdict['comment'] = int(lsplit[0])
    settingsdict['lessfiles'] = str2bool(lsplit[1])

    lsplit = lines[3].strip().split()
    settingsdict['nx'] = int(lsplit[0])
    settingsdict['nz'] = int(lsplit[1])
    settingsdict['dx'] = float(lsplit[2])
    settingsdict['dz'] = float(lsplit[3])
    settingsdict['xorig'] = float(lsplit[4])
    settingsdict['zorig'] = float(lsplit[5])

    lsplit = lines[5].replace('\'','').strip().split()
    settingsdict['inv'] = str2bool(lsplit[0])<commit_msg>Fix: Prefer 'with' to open files.<commit_after>
import re
import numpy as np

# Code in str2bool and readini pulled from github.com/bsmithyman/pygeo/pygeo/fullpy.py
# Original code is licensed LGPL; I am explicitly re-licensing this under the umbrella
# of the windtunnel MIT license. -- <NAME>

def str2bool(v):
    '''
    Converts certain string values to a boolean.
    '''

    return v.lower() in ("yes", "true", "t", "1")

def readini (infile):
    '''
    Reads (2.5-D) omega ini file of a given filename.
    '''

    with open(infile, 'r') as fp:
        lines = fp.readlines()

    settingsdict = {}

    lsplit = lines[1].strip().split()
    settingsdict['comment'] = int(lsplit[0])
    settingsdict['lessfiles'] = str2bool(lsplit[1])

    lsplit = lines[3].strip().split()
    settingsdict['nx'] = int(lsplit[0])
    settingsdict['nz'] = int(lsplit[1])
    settingsdict['dx'] = float(lsplit[2])
    settingsdict['dz'] = float(lsplit[3])
    settingsdict['xorig'] = float(lsplit[4])
    settingsdict['zorig'] = float(lsplit[5])

    lsplit = lines[5].replace('\'','').strip().split()
    settingsdict['inv'] = str2bool(lsplit[0])
{'fraction_non_alphanumeric': 0.17101193106495802, 'fraction_numerical': 0.016791869200176758, 'mean_word_length': 3.620408163265306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6242984', 'n_tokens_mistral': 792, 'n_tokens_neox': 767, 'n_words': 191}