#!/usr/bin/python ############################################################################# # Copyright (C) 2010 Spidcom # ############################################################################# import sys import os from core import MMTypeConstGen # Find the path for the MME txt file. path = os.path.dirname (__file__) # dirname function return "" if the script is run in its directory mmetxt = "%s/mme.txt" % ("." if path == "" else path) def mmtypes_list (): """Generate a dictionary containing the MMTypes.""" m = MMTypeConstGen (mmetxt) try: m.parse () except RuntimeError, e: print >> sys.stderr, "error:", e return m.mmtype_dict () if __name__ == "__main__": from optparse import OptionParser usage = "%prog outfile" parser = OptionParser (usage = usage) [options, args] = parser.parse_args() # Verify we have at most 2 arguments. if len (args) > 1: parser.error ("too many arguments") outfile = None if len (args) == 1: outfile = args.pop () m = MMTypeConstGen (mmetxt, outfile) try: m.process () except RuntimeError, e: print >> sys.stderr, "error:", e sys.exit (1)