<commit_before>import os
import sys
import re
import subprocess
import glob

from SCons.Script import *


default_exclude = set([re.compile(r'^.*\\system32\\.*$')])


def find_in_path(filename):
    for path in os.environ["PATH"].split(os.pathsep):

        candidate = os.path.join(path.strip('"'), filename)
        if os.path.isfile(candidate): return candidate

        for name in os.listdir(path):
            if name.lower() == filename.lower():
                return os.path.join(path, name)


def find_dlls(env, path, exclude = set()):
    if env['PLATFORM'] == 'win32':
        prog = env.get('FIND_DLLS_DUMPBIN')
        cmd = [prog, '/DEPENDENTS', '/NOLOGO', path]

    else:
        prog = env.get('FIND_DLLS_OBJDUMP')
        cmd = [prog, '-p', path]


    p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
    out, err = p.communicate()

    if p.returncode:
        raise Exception('Call to %s failed: %s' % (prog, err))

    for line in out.splitlines():
        if line.startswith('\tDLL Name: '): lib = line[11:]
        else:
            m = re.match(r'^\s+([^\s.]+\.[dD][lL][lL])\s*$', line)
            if m: lib = m.group(1)
            else: continue

        lib = lib.strip().lower()

        if not lib in exclude:
            exclude.add(lib)

            path = find_in_path(lib)
            if path is None:
                if env.get('FIND_DLLS_IGNORE_MISSING'): continue
                raise Exception('Lib "%s" not found' % lib)

            ok = True
            for pat in exclude:
                if isinstance(re.compile(''), pat) and pat.match(path):
                    ok = False
                    break

            if not ok: continue
<commit_msg>Don't allow any DLLs from systemew<commit_after>import os
import sys
import re
import subprocess
import glob

from SCons.Script import *


default_exclude = set([re.compile(r'^.*\\system32\\.*$')])


def find_in_path(filename):
    for path in os.environ["PATH"].split(os.pathsep):

        candidate = os.path.join(path.strip('"'), filename)
        if os.path.isfile(candidate): return candidate

        for name in os.listdir(path):
            if name.lower() == filename.lower():
                return os.path.join(path, name)


def find_dlls(env, path, exclude = set()):
    if env['PLATFORM'] == 'win32':
        prog = env.get('FIND_DLLS_DUMPBIN')
        cmd = [prog, '/DEPENDENTS', '/NOLOGO', path]

    else:
        prog = env.get('FIND_DLLS_OBJDUMP')
        cmd = [prog, '-p', path]


    p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
    out, err = p.communicate()

    if p.returncode:
        raise Exception('Call to %s failed: %s' % (prog, err))

    for line in out.splitlines():
        if line.startswith('\tDLL Name: '): lib = line[11:]
        else:
            m = re.match(r'^\s+([^\s.]+\.[dD][lL][lL])\s*$', line)
            if m: lib = m.group(1)
            else: continue

        lib = lib.strip().lower()

        if not lib in exclude:
            exclude.add(lib)

            path = find_in_path(lib)
            if path is None:
                if env.get('FIND_DLLS_IGNORE_MISSING'): continue
                raise Exception('Lib "%s" not found' % lib)

            ok = True
            for pat in exclude:
                if isinstance(pat, type(re.compile(''))) and pat.match(path):
                    ok = False
                    break

            if not ok: continue

{'fraction_non_alphanumeric': 0.14427860696517414, 'fraction_numerical': 0.004097161252560726, 'mean_word_length': 1.9618717504332757, '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': '788198', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1081, 'n_words': 279}