<commit_before># -*- coding: utf-8 -*-
"""
CLibrary.py -  Provides CLibrary class
Copyright 2010  <NAME>
Distributed under MIT/X11 license. See license.txt for more infomation.

Proxy to both CHeader and ctypes, allowing automatic type conversion and
function calling based on C header definitions.
"""


from ctypes import *
import sys, os

def find_lib(name, paths=[], dirHints=[]):
    """Search through likely directories to find non-system dlls. Return the first filepath that is found.

    **Arguments** 
    =============   ==============================================
    name            (str) The name of the file to look for.
    paths           (list)(optional) A list of directory paths to search. 
    dirHints        (list)(optional) A list of directory names within ProgramFiles or ProgramFiles(x86) to search first. Used to reduce search time.

    Directories are searched in the order specified in paths, then in 'ProgramFiles', then 'ProgramFiles(x86)'
    """

    searchPaths = paths

    for directory in ['PROGRAMFILES', 'PROGRAMFILES(X86)']:
        p = os.environ.get(directory, None)
        if p is not None:
            for d in dirHints:
                searchPaths.append(os.path.join(p, d))
            searchPaths.append(p)
    
    for path in searchPaths:
        for root, dirs, files in os.walk(path):
            if name in files:
                return os.path.join(root, name)

    
<commit_msg>Added exception and error message in find_lib() that gets raised if no files are found.<commit_after># -*- coding: utf-8 -*-
"""
CLibrary.py -  Provides CLibrary class
Copyright 2010  <NAME>
Distributed under MIT/X11 license. See license.txt for more infomation.

Proxy to both CHeader and ctypes, allowing automatic type conversion and
function calling based on C header definitions.
"""


from ctypes import *
import sys, os

def find_lib(name, paths=[], dirHints=[]):
    """Search through likely directories to find non-system dlls. Return the first filepath that is found.

    **Arguments** 
    =============   ==============================================
    name            (str) The name of the file to look for.
    paths           (list)(optional) A list of directory paths to search. 
    dirHints        (list)(optional) A list of directory names within ProgramFiles or ProgramFiles(x86) to search first. Used to reduce search time.

    Directories are searched in the order specified in paths, then in 'ProgramFiles', then 'ProgramFiles(x86)'
    """

    searchPaths = paths

    for directory in ['PROGRAMFILES', 'PROGRAMFILES(X86)']:
        p = os.environ.get(directory, None)
        if p is not None:
            for d in dirHints:
                searchPaths.append(os.path.join(p, d))
            searchPaths.append(p)
    
    for path in searchPaths:
        for root, dirs, files in os.walk(path):
            if name in files:
                return os.path.join(root, name)

    raise Exception('Could not find file named "%s". Searched recursively in %s.' % (name, str(searchPaths)))

{'fraction_non_alphanumeric': 0.12414018997707173, 'fraction_numerical': 0.008516213560432362, 'mean_word_length': 2.841509433962264, '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': '4014712', 'n_tokens_mistral': 863, 'n_tokens_neox': 807, 'n_words': 335}