<commit_before>## Copyright (c) 2012 <NAME>ics. All rights reserved.
## Use of this source code is governed by a BSD-style license that can be
## found in the COPYING file.

""" Set of tools to handle DLLs on Windows.

"""
import os
import qibuild

import logging

LOGGER = logging.getLogger(__name__)

def fix_dlls(sdk_dir, build_env=None, paths=None, mingw=False):
    """ Copy the dlls fron the toolchains and the other build dirs
    into a sdk directory, so that running the executable
    just works

    """
    if not paths:
        return
    dest = os.path.join(sdk_dir, "bin")
    dlls_to_copy = list()
    for path in paths:
        bin_dir = os.path.join(path, "bin")
        if not os.path.exists(bin_dir):
            continue
        dlls = os.listdir(bin_dir)
        dlls = [x for x in dlls if x.endswith(".dll")]
        dlls = [os.path.join(bin_dir, x) for x in dlls]
        dlls_to_copy.extend(dlls)
    if mingw:
        # Copy libgcc and mingw dll
        if not build_env:
            build_env = os.environ.copy()
        env_path = build_env["PATH"]
        candidates = env_path.split(os.path.pathsep)
        for candidate in candidates:
            if not os.path.exists(candidate):
                continue
            dlls = os.listdir(candidate)
            dlls = [x for x in dlls if x.endswith(".dll")]
            dlls_to_copy.extend([os.path.join(candidate, x) for x in dlls
                if x.startswith("libgcc")])
            dlls_to_copy.extend([os.path.join(candidate, x) for x in dlls
                if x.startswith("mingw")])

    for dll_to_copy in dlls_to_copy:
        try:
            qibuild.sh.safe_copy(dll_to_copy, dest)
        except Exception, e:
            mess  = "Could not copy %s to %s\n" % (dll_to_copy, dest)
            mess += "Error was: %s\n" % e
            LOGGER.warning(mess)

<commit_msg>qibuild.dlls: subtle bug fix<commit_after>## Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
## Use of this source code is governed by a BSD-style license that can be
## found in the COPYING file.

""" Set of tools to handle DLLs on Windows.

"""
import os
import qibuild

import logging

LOGGER = logging.getLogger(__name__)

def fix_dlls(sdk_dir, build_env=None, paths=None, mingw=False):
    """ Copy the dlls fron the toolchains and the other build dirs
    into a sdk directory, so that running the executable
    just works

    """
    if not paths:
        return
    dest = os.path.join(sdk_dir, "bin")
    qibuild.sh.mkdir(dest, recursive=True)
    dlls_to_copy = list()
    for path in paths:
        bin_dir = os.path.join(path, "bin")
        if not os.path.exists(bin_dir):
            continue
        dlls = os.listdir(bin_dir)
        dlls = [x for x in dlls if x.endswith(".dll")]
        dlls = [os.path.join(bin_dir, x) for x in dlls]
        dlls_to_copy.extend(dlls)
    if mingw:
        # Copy libgcc and mingw dll
        if not build_env:
            build_env = os.environ.copy()
        env_path = build_env["PATH"]
        candidates = env_path.split(os.path.pathsep)
        for candidate in candidates:
            if not os.path.exists(candidate):
                continue
            dlls = os.listdir(candidate)
            dlls = [x for x in dlls if x.endswith(".dll")]
            dlls_to_copy.extend([os.path.join(candidate, x) for x in dlls
                if x.startswith("libgcc")])
            dlls_to_copy.extend([os.path.join(candidate, x) for x in dlls
                if x.startswith("mingw")])

    for dll_to_copy in dlls_to_copy:
        try:
            qibuild.sh.safe_copy(dll_to_copy, dest)
        except Exception, e:
            mess  = "Could not copy %s to %s\n" % (dll_to_copy, dest)
            mess += "Error was: %s\n" % e
            LOGGER.warning(mess)


{'fraction_non_alphanumeric': 0.10282098602689164, 'fraction_numerical': 0.0021091484313208544, 'mean_word_length': 2.1882352941176473, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7211639', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1264, 'n_words': 372}