#!/usr/bin/python
# License: LGPL
# Keith Dart <kdart@kdart.com>

"""
Usage: mib2py [-AE] [-p <preload>] <modulename> ...

Where:
    -A  = Also compile ALL modules (imported and defined).
    -p  = Preload a module before loading the main module 
          (can be used multiple times)
    -E  = Compile every installed SMI module. This can take a while.

"""

import sys, getopt
from pycopia.SMI import Compile

preloads = []
allflag = 0
everythingflag = 0

try:
    optlist, args = getopt.getopt(sys.argv[1:], "EAp:")
except:
    print __doc__
    sys.exit(1)

for opt, val in optlist:
    if opt == "-p":
        preloads.append(val)
    elif opt == "-A":
        allflag = 1
    elif opt == "-E":
        everythingflag = 1

if everythingflag:
    Compile.compile_everything(allflag)
elif args:
    for modname in args:
        Compile.compile_module(modname, preloads, allflag)
else:
    print __doc__

