(directory, file_pattern, path_match,
           follow_symlinks=True, output=False, colored=False,
           ignore_hidden=True, delete=False, exec_command=False,
           ignore_case=False, ignore_vcs=False, return_results=True,
           fuzzy=False, return_exec_result=False, run_module_command=False,
           program=False)
Search the files matching the pattern.
        The files will be returned as a list, and can be optionally printed

        if return_exec_result is True in no return_results are specified,
        the function will return 1 if any execution has been wrong
Search the files matching the pattern.
        The files will be returned as a list, and can be optionally printed
Search the files matching the pattern . The files will be returned as a list and can be optionally printed
def search(directory, file_pattern, path_match,
           follow_symlinks=True, output=False, colored=False,
           ignore_hidden=True, delete=False, exec_command=False,
           ignore_case=False, ignore_vcs=False, return_results=True,
           fuzzy=False, return_exec_result=False, run_module_command=False,
           program=False):
    '''
        Search the files matching the pattern.
        The files will be returned as a list, and can be optionally printed

        if return_exec_result is True in no return_results are specified,
        the function will return 1 if any execution has been wrong
    '''

    # Create the compare function
    compare = create_comparison(file_pattern, ignore_case, fuzzy)

    if return_results:
        results = []

    exec_result = 0

    for root, sub_folders, files in os.walk(directory, topdown=True,
                                            followlinks=follow_symlinks):
        if SORT_RESULT:
            sub_folders.sort()
            files.sort()
        # Ignore hidden and VCS directories.
        fsubfolders = filtered_subfolders(sub_folders, ignore_hidden,
                                          ignore_vcs)

        ffiles = filtered_files(files, ignore_hidden, ignore_vcs)

        # Search in files and subfolders
        for filename in itertools.chain(ffiles, fsubfolders):
            to_match = os.path.join(root, filename) if path_match else filename
            smatch = compare(to_match)
            if smatch:
                if not path_match:
                    # Add the fullpath to the prefix
                    smatch[0] = os.path.join(root, smatch[0])

                full_filename = os.path.join(root, filename)

                if delete:
                    if delete_file(full_filename):
                        exec_result = 1

                elif exec_command:
                    if execute_command(exec_command[0], full_filename):
                        exec_result = 1

                elif run_module_command:
                    if run_module(run_module_command, full_filename):
                        exec_result = 1

                elif program:
                    if execute_python_string(program, full_filename):
                        exec_result = 1

                elif output:
                    print_match(smatch, colored)

                if return_results:
                    results.append(full_filename)

    if return_results:
        return results
    elif return_exec_result:
        return exec_result
def search ( directory , file_pattern , path_match , follow_symlinks = True , output = False , colored = False , ignore_hidden = True , delete = False , exec_command = False , ignore_case = False , ignore_vcs = False , return_results = True , fuzzy = False , return_exec_result = False , run_module_command = False , program = False ) : # Create the compare function compare = create_comparison ( file_pattern , ignore_case , fuzzy ) if return_results : results = [ ] exec_result = 0 for root , sub_folders , files in os . walk ( directory , topdown = True , followlinks = follow_symlinks ) : if SORT_RESULT : sub_folders . sort ( ) files . sort ( ) # Ignore hidden and VCS directories. fsubfolders = filtered_subfolders ( sub_folders , ignore_hidden , ignore_vcs ) ffiles = filtered_files ( files , ignore_hidden , ignore_vcs ) # Search in files and subfolders for filename in itertools . chain ( ffiles , fsubfolders ) : to_match = os . path . join ( root , filename ) if path_match else filename smatch = compare ( to_match ) if smatch : if not path_match : # Add the fullpath to the prefix smatch [ 0 ] = os . path . join ( root , smatch [ 0 ] ) full_filename = os . path . join ( root , filename ) if delete : if delete_file ( full_filename ) : exec_result = 1 elif exec_command : if execute_command ( exec_command [ 0 ] , full_filename ) : exec_result = 1 elif run_module_command : if run_module ( run_module_command , full_filename ) : exec_result = 1 elif program : if execute_python_string ( program , full_filename ) : exec_result = 1 elif output : print_match ( smatch , colored ) if return_results : results . append ( full_filename ) if return_results : return results elif return_exec_result : return exec_result