docs: def dataverse_download_doi(doi,
                             local_fname=None,
                             file_requirements={},
                             clobber=False):
      """
      Downloads a file from the Dataverse, using a DOI and set of metadata
      parameters to locate the file.
  
      Args:
          doi (str): Digital Object Identifier (DOI) containing the file.
          local_fname (Optional[str]): Local filename to download the file to. If
              `None`, then use the filename provided by the Dataverse. Defaults to
              `None`.
          file_requirements (Optional[dict]): Select the file containing the
              given metadata entries. If multiple files meet these requirements,
              only the first in downloaded. Defaults to `{}`, corresponding to no
              requirements.
  
      Raises:
          DownloadError: Either no matching file was found under the given DOI, or
              the MD5 sum of the file was not as expected.
          requests.exceptions.HTTPError: The given DOI does not exist, or there
              was a problem connecting to the Dataverse.
  
      """
      metadata = dataverse_search_doi(doi)
  
      def requirements_match(metadata):
          for key in file_requirements.keys():
              if metadata['dataFile'].get(key, None) != file_requirements[key]:
                  return False
          return True
  
      for file_metadata in metadata['data']['latestVersion']['files']:
          if requirements_match(file_metadata):
              file_id = file_metadata['dataFile']['id']
              md5sum = file_metadata['dataFile']['md5']
  
              if local_fname is None:
                  local_fname = file_metadata['dataFile']['filename']
  
              # Check if the file already exists on disk
              if (not clobber) and os.path.isfile(local_fname):
                  print('Checking existing file to see if MD5 sum matches ...')
                  md5_existing = get_md5sum(local_fname)
                  if md5_existing == md5sum:
                      print('File exists. Not overwriting.')
                      return
  
              print("Downloading data to '{}' ...".format(local_fname))
  
              dataverse_download_id(file_id, md5sum,
                                    fname=local_fname, clobber=False)
  
              return
  
      raise DownloadError(
          'No file found under the given DOI matches the requirements.\n'
          'The metadata found for this DOI was:\n'
          + json.dumps(file_metadata, indent=2, sort_keys=True))