<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def parseprofile(profilelog, out):
    '''
    Parse a profile log and print the result on screen
    '''
    file = open(out, 'w') # opening the output file
    print('Opening the profile in %s...' % profilelog)
    p = pstats.Stats(profilelog, stream=file) # parsing the profile with pstats, and output everything to the file

    print('Generating the stats, please wait...')
    file.write("=== All stats:\n")
    p.strip_dirs().sort_stats(-1).print_stats()
    file.write("=== Cumulative time:\n")
    p.sort_stats('cumulative').print_stats(100)
    file.write("=== Time:\n")
    p.sort_stats('time').print_stats(100)
    file.write("=== Time + cumulative time:\n")
    p.sort_stats('time', 'cum').print_stats(.5, 'init')
    file.write("=== Callees:\n")
    p.print_callees()
    file.write("=== Callers:\n")
    p.print_callers()
    #p.print_callers(.5, 'init')
    #p.add('fooprof')
    file.close()
    print('Stats generated and saved to %s.' % out)
    print('Everything is done. Exiting')