<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def search_worker(self, regex, directory_path, names, binary=False, callback=None):
 """ build a DirectoryResult for the given regex, directory path, and file names """

        try:
            result = DirectoryResult(directory_path)
            def find_matches(name):
                full_path = path.join(directory_path, name)
                file_contents = get_file_contents(full_path, binary)
                start = 0
                match = regex.search(file_contents, start)
                while match:
                    result.put(name, file_contents, match)
                    start = match.end()
                    match = regex.search(file_contents, start)
            for name in names:
                try:
                    find_matches(name)
                except IOError:
                    pass
            if callback:
                callback(result)
        except KeyboardInterrupt, e:
            exit(1)