<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def potcar_spec( filename ):
 """ Returns a dictionary specifying the pseudopotentials contained in a POTCAR file. Args: filename (Str):
 The name of the POTCAR file to process. Returns: (Dict):
 A dictionary of pseudopotential filename: dataset pairs, e.g. { 'Fe_pv': 'PBE_54', 'O', 'PBE_54' } """

    p_spec = {}
    with open( filename, 'r' ) as f:
        potcars = re.split('(End of Dataset\n)', f.read() )
    potcar_md5sums = [ md5sum( ''.join( pair ) ) for pair in zip( potcars[::2], potcars[1:-1:2] ) ]
    for this_md5sum in potcar_md5sums:
        for ps in potcar_sets:
            for p, p_md5sum in potcar_md5sum_data[ ps ].items():
                if this_md5sum == p_md5sum:
                    p_spec[ p ] = ps
    if len( p_spec ) != len( potcar_md5sums ):
        raise ValueError( 'One or more POTCARs did not have matching md5 hashes' )
    return p_spec