Beispiel #1
0
    def __init__(self, lang, basedirs = None):
        if (basedirs == None):
            basedirs = vapp.default_prompt_dirs()
	self._map = dict()
        for basedir in basedirs:
            self.init(os.path.abspath(basedir), lang, self._map)
Beispiel #2
0
    def __init__(self, argv):
	self.__opts = Opts()
	self.enum_start = None
        self.g711_nonconverable_exts = [ ]

	self.__lang = 'en'
	try:
	    opts, args = getopt.getopt(argv[1:], 'dol:f:p:', 
		    [ 'debug', 'optimize', 'lang=', 'promptpath',
		      'filter-untranslated', 'enum=', 'enum-suffix=',
                      'extra-extensions='])
	    for o, a in opts:
		if (o == '-l' or o == '--lang'):
		    self.__lang = a
		elif (o == '-p' or o == "--promptpath"):
		    if (not a.endswith('/')):
			a += '/'
		    self.prompt_path = [ a ]
		elif (o == "-o" or o == "--optimize"):
		    self.optimize = True
		elif (o == "-d" or o == "--debug"):
		    self.debug = True
                elif (o == "--filter-untranslated"):
                    self.__opts.filter_untranslated = True
		elif (o == '--enum'):
		    try:
			self.enum_start = int(a)
		    except ValueError:
			raise MyException("Bad argument for --enum: '%s'" % a)
		elif (o == '--enum-suffix'):
		    self.__enum_suffix = a
		elif (o == '--extra-extensions'):
		    self.g711_nonconverable_exts = re.split(',|', a)
		else:
		    sys.__stderr__.write("Unhandled option: '%s' = '%s'\n" % (o, a))
	    self.__phrases = PhraseContainer(self.__lang, self.__opts)
	    if (len(argv) < 3):
		raise MyException("error: No command given")
            handler = None
	    if (argv[len(argv) - 2] == 'list'):
		if (argv[len(argv) - 1] == 'phrases'):
		    handler = self.doListPhrases
		elif (argv[len(argv) - 1] == 'mappings'):
		    handler = self.doListMappings
		elif (argv[len(argv) - 1] == 'unmapped'):
		    handler = self.doListUnmapped
		elif (argv[len(argv) - 1] == 'orphans'):
		    handler = self.doListOrphans
	    elif (argv[len(argv) - 2] == 'verify'):
		if (argv[len(argv) - 1] == 'mappings'):
		    handler = self.doVerifyMappings
	    elif (argv[len(argv) - 2] == 'make'):
		if (argv[len(argv) - 1] == 'stoplist'):
                    handler = self.makeStopList
            elif (argv[-2] == 'generate'):
                if (argv[-1] == 'tests'):
                    handler = self.generateTests
            if (handler == None):
		raise MyException("error: No command found")

            if self.prompt_path == None:
                self.prompt_path = vapp.default_prompt_dirs()

            self.__speech_synth = vapp.SpeechSynth.Chunked.Chunked(self.__lang, self.prompt_path)
            handler()

	except MyException, e:
            usage(e)