#!/usr/bin/python
# This file is part of the Coral project.
# Please read the copyright notice in the LICENSE file.
#
# -*- coding: UTF-8 -*-
#
# load - just try to load a model into Coral and exit
#
# SYNOPSIS
#
# Explained in usage()
#
# DESCRIPTION
#
# Simply loads the models on the command line.
# If anything fails, exits with an error code.
#
# AUTHORS
#
# Marcus Alanen <maalanen@abo.fi> 2005
#

import sys

def main(arguments):
    def usage():
        print """
Usage: load [ --help | --version | files... ]

Options:
  --help         Display this information
  --version      Display version information and exit

The fiven files are loaded and an errorcode is given if anything failed.
"""

    def version():
        import coral
        print "This is Coral version", coral.version, \
              " (load script)"
        
    import getopt
    import os

    try:
        opts, args = getopt.getopt(arguments, "chp:r:f:n:m:",
                                   ["help", "version", "unique-strings" ])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    for o,a in opts:
        if o in ("-h", "--help"):
            usage()
            sys.exit(0)
        elif o in ("--version"):
            version()
            sys.exit(0)
        else:
            usage()
            sys.exit(2)

    try:
        import coral
        projects = []
        for i in args:
            p = coral.loadDocument(i)
            projects.append(p)
    except SystemExit:
        pass
    except:
        sys.exit(2)
if __name__ == "__main__":
    main(sys.argv[1:])
