import hashlib


def calculate_checksum(filename):
    """
    Calculate the sha1 checksum of a file (in chunks)
    :param str filename: The file to calculate the checksum of
    :param bool any_order: Sort lines before checksumming
    :return str checksum: The calculated checksum
    """
    file_hash = hashlib.sha1()
    with open(filename, 'rb') as f:
        buf = f.read()
        while len(buf) > 0:
            file_hash.update(buf)
            buf = f.read(128)
        return file_hash.hexdigest()