code: def parse_requirements(file_):
      
      modules = []
      delim = ["<", ">", "=", "!", "~"]  # https://www.python.org/dev/peps/pep-0508/#complete-grammar
  
      try:
          f = open_func(file_, "r")
      except OSError:
          logging.error("Failed on file: {}".format(file_))
          raise
      else:
          data = [x.strip() for x in f.readlines() if x != "\n"]
      finally:
          f.close()
  
      data = [x for x in data if x[0].isalpha()]
  
      for x in data:
          if not any([y in x for y in delim]):  # Check for modules w/o a specifier.
              modules.append({"name": x, "version": None})
          for y in x:
              if y in delim:
                  module = x.split(y)
                  module_name = module[0]
                  module_version = module[-1].replace("=", "")
                  module = {"name": module_name, "version": module_version}
  
                  if module not in modules:
                      modules.append(module)
  
                  break
  
      return modules
docs: Parse a requirements formatted file.
  
      Traverse a string until a delimiter is detected, then split at said
      delimiter, get module name by element index, create a dict consisting of
      module:version, and add dict to list of parsed modules.
  
      Args:
          file_: File to parse.
  
      Raises:
          OSerror: If there's any issues accessing the file.
  
      Returns:
          tuple: The contents of the file, excluding comments.