<commit_before>from __future__ import print_function
import os


def find_in_workspaces(project, path=None, search_in=None):
    if path is None:
        path = ''

    # define all possible subfolders
    subfolders = {
      'bin': 'bin',
      'lib': 'lib',
      'libexec': os.path.join('lib', project),
      'share': os.path.join('share', project),
    }
    if not search_in:
        search_in = subfolders.keys()

    env_name = 'CATKIN_WORKSPACES'
    workspaces = os.environ[env_name].split(';') if env_name in os.environ and os.environ[env_name] != '' else []

    # search for path in all workspaces
    checked = []
    for workspace in workspaces:
        workspace = workspace.split(':')[0]

        # check subfolders for existance
        subfolders_exist = {}
        for key, subfolder in subfolders.items():
            subfolder = os.path.join(workspace, subfolder, '')
            subfolders_exist[key] = os.path.exists(subfolder)

        # check if project is part of this workspace
        if not subfolders_exist['libexec'] and not subfolders_exist['share']:
            continue

        # find all matching paths
        matches = []
        for key in search_in:
            if not subfolders_exist[key]:
                continue
            candidate = os.path.join(workspace, subfolders[key], path)
            checked.append(candidate)
            if os.path.exists(candidate):<commit_msg>fixed find_in_workspaces with single search dir<commit_after>from __future__ import print_function
import os


def find_in_workspaces(project, path=None, search_in=None):
    if path is None:
        path = ''

    # define all possible subfolders
    subfolders = {
      'bin': 'bin',
      'lib': 'lib',
      'libexec': os.path.join('lib', project),
      'share': os.path.join('share', project),
    }
    if search_in is None:
        search_in = subfolders.keys()
    if not isinstance(search_in, list):
        search_in = [search_in]

    env_name = 'CATKIN_WORKSPACES'
    workspaces = os.environ[env_name].split(';') if env_name in os.environ and os.environ[env_name] != '' else []

    # search for path in all workspaces
    checked = []
    for workspace in workspaces:
        workspace = workspace.split(':')[0]

        # check subfolders for existance
        subfolders_exist = {}
        for key, subfolder in subfolders.items():
            subfolder = os.path.join(workspace, subfolder, '')
            subfolders_exist[key] = os.path.exists(subfolder)

        # check if project is part of this workspace
        if not subfolders_exist['libexec'] and not subfolders_exist['share']:
            continue

        # find all matching paths
        matches = []
        for key in search_in:
            if not subfolders_exist[key]:
                continue
            candidate = os.path.join(workspace, subfolders[key], path)
            checked.append(candidate)
            if os.path.exists(candidate):
{'fraction_non_alphanumeric': 0.10670731707317073, 'fraction_numerical': 0.0006775067750677507, 'mean_word_length': 2.449766355140187, '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': '5654967', 'n_tokens_mistral': 894, 'n_tokens_neox': 878, 'n_words': 229}