<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hash(filename, algorithm='sha256'):
 """ Hash the given filename. Unavailable in `pip<8.0.0` """

    if incompatible:
        raise Incompatible

    if algorithm not in ['sha256', 'sha384', 'sha512']:
        raise InvalidArguments('Algorithm {} not supported'.format(algorithm))

    result = call('hash', '--algorithm', algorithm, filename)

    # result is of the form:
    # <filename>:\n--hash=<algorithm>:<hash>\n
    return result.strip().split(':')[-1]