def calculate_checksum_on_iterator(
    itr, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
    """Calculate the checksum of an iterator.

    Args:
      itr: iterable
        Object which supports the iterator protocol.

      algorithm: str
        Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.

    Returns:
      str : Checksum as a hexadecimal string, with length decided by the algorithm.

    """
    checksum_calc = get_checksum_calculator_by_dataone_designator(algorithm)
    for chunk in itr:
        checksum_calc.update(chunk)
    return checksum_calc.hexdigest()
Calculate the checksum of an iterator.

    Args:
      itr: iterable
        Object which supports the iterator protocol.

      algorithm: str
        Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.

    Returns:
      str : Checksum as a hexadecimal string, with length decided by the algorithm.