# Path: vasppy/summary.py
# def potcar_spec(filename, return_hashes=False):
#     """
#     Returns a dictionary specifying the pseudopotentials contained in a POTCAR file.
# 
#     Args:
#         filename (str): The name of the POTCAR file to process.
#         return_hash (bool): If True the return dictionary values will be the md5 hashes of
#             the component pseudopotential files.
# 
#     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:
#                     if return_hashes:
#                         p_spec[p] = this_md5sum
#                     else:
#                         p_spec[p] = ps
#     if len(set(p_spec)) != len(set(potcar_md5sums)):
#         raise ValueError( 'One or more POTCARs did not have matching md5 hashes' )
#     return p_spec


from vasppy.summary import potcar_spec
import argparse
#! /usr/bin/env python3


def parse_command_line_arguments():
    parser = argparse.ArgumentParser( description='Generate POTCAR specification based on hashing individual pseudopotential strings' )
    parser.add_argument('potcar', help="filename of the VASP POTCAR to be processed", nargs='?', default='POTCAR' )
    parser.add_argument('--hash', help="return the md5 hashes of the individual pseudopotential strings", action='store_true') 
    args = parser.parse_args()
    return args

def main():
    args = parse_command_line_arguments()
    if args.hash:
        hashes = {}
        for p, md5hash in potcar_spec(args.potcar, return_hashes=True).items():
            hashes[p] = md5hash

# Path: vasppy/summary.py
# def potcar_spec(filename, return_hashes=False):
#     """
#     Returns a dictionary specifying the pseudopotentials contained in a POTCAR file.
# 
#     Args:
#         filename (str): The name of the POTCAR file to process.
#         return_hash (bool): If True the return dictionary values will be the md5 hashes of
#             the component pseudopotential files.
# 
#     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:
#                     if return_hashes:
#                         p_spec[p] = this_md5sum
#                     else:
#                         p_spec[p] = ps
#     if len(set(p_spec)) != len(set(potcar_md5sums)):
#         raise ValueError( 'One or more POTCARs did not have matching md5 hashes' )
#     return p_spec


# Path: vasppy/scripts/potcar_spec.py
from vasppy.summary import potcar_spec
import argparse

#! /usr/bin/env python3


def parse_command_line_arguments():
    parser = argparse.ArgumentParser( description='Generate POTCAR specification based on hashing individual pseudopotential strings' )
    parser.add_argument('potcar', help="filename of the VASP POTCAR to be processed", nargs='?', default='POTCAR' )
    parser.add_argument('--hash', help="return the md5 hashes of the individual pseudopotential strings", action='store_true') 
    args = parser.parse_args()
    return args

def main():
    args = parse_command_line_arguments()
    if args.hash:
        hashes = {}
        for p, md5hash in potcar_spec(args.potcar, return_hashes=True).items():
            hashes[p] = md5hash

    for p, ps in potcar_spec(args.potcar).items():