Main function of this example.

def main():
    """ Main function of this example. """
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--digest', default="md5", help="Digest to use",
        choices=sorted(
            getattr(hashlib, 'algorithms', None)
            or hashlib.algorithms_available))
    parser.add_argument(
        '--url', default="http://example.org", help="URL to load")
    parser.add_argument(
        '-o', '--output', type=argparse.FileType('wb'), metavar='FILE',
        default='-', help="Where to write the retrieved conentent")
    opts = parser.parse_args()
    request = requestlib.Request(opts.url)
    reader = requestlib.urlopen(request)
    stream = written_hash_proxy(
        opts.output.buffer if hasattr(opts.output, 'buffer') else opts.output,
        name=opts.digest)
    for chunk in reader:
        stream.write(chunk)
    stream.flush()
    print("{} of {} is {}".format(
        proxy.state(stream).digest.name, opts.url,
        proxy.state(stream).digest.hexdigest()))