#!/usr/bin/python
"""Print out the sha256 hash corresponding to a given contents file."""
# Copyright (C) 2007 One Laptop Per Child Association, Inc.
# Licensed under the terms of the GNU GPL v2 or later; see COPYING for details.
# Written by C. Scott Ananian <cscott@laptop.org>

from bitfrost.contents.utils import UnifiedContents

def main():
    from optparse import OptionParser
    from bitfrost.contents import VERSION_INFO
    parser = OptionParser(usage='%prog contents-file')
    parser.add_option('--version',action='store_true',dest='version',
                      default=False,
                      help="display version and license information.")
    (options, args) = parser.parse_args()
    if options.version:
        print VERSION_INFO
    if not args:
        parser.error('The contents file argument is required.')
    print UnifiedContents(args[0]).contents_hash()

if __name__ == '__main__': main ()
