<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def print_result(self, directory_result):
 """ Print out the contents of the directory result, using ANSI color codes if supported """

        for file_name, line_results_dict in directory_result.iter_line_results_items():
            full_path = path.join(directory_result.directory_path, file_name)
            self.write(full_path, 'green')
            self.write('\n')
            for line_number, line_results in sorted(line_results_dict.items()):
                self.write('%s: ' % (line_results[0].line_number))
                out = list(line_results[0].left_of_group + line_results[0].group + line_results[0].right_of_group)
                offset = 0
                for line_result in line_results:
                    group_length = len(line_result.group)
                    out.insert(offset+line_result.left_offset-1, self.colors['blue'])
                    out.insert(offset+line_result.left_offset+group_length, self.colors['end'])
                    offset += group_length + 1
                self.write(''.join(out)+'\n')
            self.write('\n')