1import os
2import fnmatch
3
4#find all files under a specified directory that matches specified pattern
5def files_find(pattern, directory):
6    gxps = []
7    for root, dirnames, filenames in os.walk(directory):
8        for extensions in pattern:
9            for filename in fnmatch.filter(filenames, extensions):
10                gxps.append(os.path.join(root, filename))
11    return gxps
12
13
14def project_search(start_dir, search_samples = True, search_tutorials = True, search_internal_examples = True):
15    gxps = []
16    if search_samples is True:
17        gxps = files_find(['*.gxp'], start_dir + '\\samples')
18
19    if search_internal_examples is True:
20        gxps += files_find(['*.gxp'], start_dir + '\\test\example_internal')
21
22    if search_tutorials is True:
23        gxps += files_find(['*.gxp'], start_dir + '\\tutorials')
24
25    return gxps
26
27def source_file_search(start_dir):
28    solutions = files_find(['*.c'], start_dir + '\\samples')
29    solutions += files_find(['*.c'], start_dir + '\\test\example_internal')
30    solutions += files_find(['*.c'], start_dir + '\\tutorials')
31    return solutions
32
33def sln_file_search(start_dir):
34    solutions = files_find(['*.vcxproj'], start_dir + '\\samples')
35    solutions += files_find(['*.vcxproj'], start_dir + '\\test\example_internal')
36    solutions += files_find(['*.vcxproj'], start_dir + '\\tutorials')
37    return solutions