import argparse

parser = argparse.ArgumentParser()

parser.add_argument("-v", "--validated", help="A file containing a list of validated checksums generated by cksum", type=str, required = True)
parser.add_argument("-d", "--downloaded", help="A file containing a list of checksums generated by cksum", type=str, required = True)

args = parser.parse_args()

# Read each file into a list
with open(args.validated) as f:
  validated = f.readlines()
with open(args.downloaded) as f:
  downloaded = f.readlines()

# Filter unnecessary data out of file line lists
filtered = []
for v in validated:
  if ".hdf" in v:
    filtered.append(v)
validated = filtered

filtered = []
for d in downloaded:
  if ".hdf" in d:
    filtered.append(d)
downloaded = filtered

# List to store files which were not downloaded and invalidly downloaded files
notDownloadedFiles = []
invalidFiles = []

# For each validated item
for v in validated:

  # Get the parts
  parts = v.split()
  checksum = parts[0]
  size = parts[1]
  file = parts[2]

  # Boolean for if the file is even downloaded
  fileFound = False

  # For each file downloaded
  for d in downloaded:

    parts = d.split()
    dChecksum = parts[0]
    dSize = parts[1]
    dFile = parts[2]

    # There is a checksum entry
    if file == dFile:

      fileFound = True

      # The checksum and file size are valid
      if checksum == dChecksum and size == dSize:

        print file + " is validated"

      # The file must be invalid
      else:

        invalidFiles.append(file)

  # The validated file was not found in the downloaded checksum list
  if fileFound == False:

    notDownloadedFiles.append(file)

# Output results
print "\n"
print str(len(notDownloadedFiles)) + " files not downloaded"

for f in notDownloadedFiles:

  print f

print str(len(invalidFiles)) + " invalid files found"

for f in invalidFiles:

  print f
import argparse

parser = argparse.ArgumentParser()

parser.add_argument("-v", "--validated", help="A file containing a list of validated checksums generated by cksum", type=str, required = True)
parser.add_argument("-d", "--downloaded", help="A file containing a list of checksums generated by cksum", type=str, required = True)

args = parser.parse_args()

# Read each file into a list
with open(args.validated) as f:
  validated = f.readlines()
with open(args.downloaded) as f:
  downloaded = f.readlines()

# Filter unnecessary data out of file line lists
filtered = []
for v in validated:
  if ".hdf" in v:
    filtered.append(v)
validated = filtered

filtered = []
for d in downloaded:
  if ".hdf" in d:
    filtered.append(d)
downloaded = filtered

# List to store files which were not downloaded and invalidly downloaded files
notDownloadedFiles = []
invalidFiles = []

# For each validated item
for v in validated:

  # Get the parts
  parts = v.split()
  checksum = parts[0]
  size = parts[1]
  file = parts[2]

  # Boolean for if the file is even downloaded
  fileFound = False

  # For each file downloaded
  for d in downloaded:

    # There is a checksum entry
    if file in d:

      fileFound = True

      parts = d.split()
      dChecksum = parts[0]
      dSize = parts[1]
      dFile = parts[2]

      # The file, checksum and file size are valid
      if file == dFile and checksum == dChecksum and size == dSize:

        print file + " is validated"

      # The file must be invalid
      else:

        invalidFiles.append(file)

  # The validated file was not found in the downloaded checksum list
  if fileFound == False:

    notDownloadedFiles.append(file)

# Output results
print "\n"
print str(len(notDownloadedFiles)) + " files not downloaded"

for f in notDownloadedFiles:

  print f

print str(len(invalidFiles)) + " invalid files found"

for f in invalidFiles:

  print f
Revert "Checksum validator fix"