;๒ nšฟ?c@sฮdkZdkZdkZdkZdkZd„Zdfd„ƒYZdfd„ƒYZdefd„ƒYZ dfd „ƒYZ e d jo8e ƒZ e i ƒe iƒe iƒeid ƒndS( NcCsDtid}|idƒ}|t|ƒd}|i|dƒSdS(Nis/is(ssyssargvs psychepathssplitssslensreplace(s psychepathss((s/home/sfvlug/psyche/psyche.pysget_psychepath s sFestivalWrappercBs tZdZd„Zd„ZRS(sD Nothing more than a wrapper around a pipe to festival. cCs!tiid|ƒ||_dS(sV Store the command that is going to be the receiving end of pipe. sinitializing %s N(ssyssstderrswrites program_namesselfs_FestivalWrapper__pipe(sselfs program_name((s/home/sfvlug/psyche/psyche.pys__init__scCs4ti|idƒ}|i|dƒ|iƒdS(sณ Open the pipe, write to it, and close the pipe. This is necessary because festival is retarded and needs a a closed pipe to be happy. sws N(sosspopensselfs_FestivalWrapper__pipesfswritesargsclose(sselfsargsf((s/home/sfvlug/psyche/psyche.pys__call__s(s__name__s __module__s__doc__s__init__s__call__(((s/home/sfvlug/psyche/psyche.pysFestivalWrappers  s SphinxWrappercBs,tZdZd„Zdd„Zd„ZRS(s4 Nothing more than a wrapper to sphinx. cCs{tidtiƒ|_tiid|ƒt i |dƒ|_ x3|ii |i ddƒƒiƒdjoqDqDWdS(sB Open the pipe and read until sphinx is ready sๅ(\[silence\])* (Listening)* (READY)* (\[initializing\])* s&initializing %s, this may take awhile srsquietisN(srescompilesVERBOSEsselfs_SphinxWrapper__readyssyssstderrswrites program_namesosspopens_SphinxWrapper__pipessearchsgetlinesgroup(sselfs program_name((s/home/sfvlug/psyche/psyche.pys__init__)s+icCs|iiƒSdS(s๊ Return the next line sitting in the pipe. input = self.__src.readline() if input != '' and quiet==0: sys.stderr.write('SphinxWrapper.getline(): %s '%input) return input N(sselfs_SphinxWrapper__pipesreadline(sselfsquiet((s/home/sfvlug/psyche/psyche.pysgetline7scCsdS(s$ close the pipe N((sself((s/home/sfvlug/psyche/psyche.pysdieAs(s__name__s __module__s__doc__s__init__sgetlinesdie(((s/home/sfvlug/psyche/psyche.pys SphinxWrapper%s   s PsycheOffcBstZRS(N(s__name__s __module__(((s/home/sfvlug/psyche/psyche.pys PsycheOffHssPsychecBsPtZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS( NcCs8d|_tidtiƒ|_d|_|iƒdS(sๆ Set up the listening process. Set proper paths. self.line is a regex to parse the sphinx output. self.build_dictionary() reads all the settings. self.festival is the output target. is  (?:(?:(?:.*:[ ])(?:\[.*\][ ])*)+) # num: or []s (.*) # what we want (?:\[.*\])* # trailing []s spsyche is ready for inputN(sselfsrunningsrescompilesVERBOSEslinesgreetingsbuild_dictionary(sself((s/home/sfvlug/psyche/psyche.pys__init__Ms   cCst|idƒ|_dS(Nsfestival(sFestivalWrappersselfssettingssfestival(sself((s/home/sfvlug/psyche/psyche.pys load_festival^scCst|idƒ|_dS(Nssphinx(s SphinxWrappersselfssettingsssphinx(sself((s/home/sfvlug/psyche/psyche.pys load_sphinxascCs*|i|ƒ}|djon|dddgjo|idƒt‚nฺ||ijoDtii d|i ƒƒt i |i|ƒi ƒ}|d}ne||ijo4tii d|i ƒƒ|i|i|ƒ}n!tii d|i ƒƒd }tii d |ƒ|i|ƒd S( s6 Receive and process piped input. snonesshutdownsquits[exit]spsyche is shutting downs"%s" was understood! s s*await_input: invalid command received: %s ss%s N(sselfs parse_linescur_linescur_cmdsfestivals PsycheOffsscriptedssyssstderrswritesstripsosspopensreadsxsbuiltinss eval_builtin(sselfscur_linescur_cmdsx((s/home/sfvlug/psyche/psyche.pys__call__ds$   cCs”|i|iƒd}xwnoo|iiƒ}|ddgjoIy|i|ƒWq‹tj o%ti i dƒ|ii ƒPq‹Xqq WdS(s‰ Grab an input line from sphinx, and pipe command to __call__ Repeat until QUIT command is received from sphinx. sis sawait_input: halting N( sselfsfestivalsgreetingscur_cmdssphinxsgetlines__call__s PsycheOffssyssstderrswritesdie(sselfscur_cmd((s/home/sfvlug/psyche/psyche.pys await_input€s cCsA|iƒ}tt|dƒ|dƒ|dƒ}|iƒSdS(sร Import the appropriate module, create an instant of the appropriate object, and invoke the get_result() method of that object to return a festival-ready string. iiN(sargsssplitsgetattrs __import__spostprocs get_result(sselfsargsspostproc((s/home/sfvlug/psyche/psyche.pys eval_builtin’s 'cCsBy$|ii|ƒdiƒiƒSWntj o dSnXdS(sฐ string <- Psyche.parse_line( string ) Parse a nnn: COMMAND formatted line. If there are no properly formatted strings, return none isnoneN(sselfslinesfindalls input_linesstripslowers IndexError(sselfs input_line((s/home/sfvlug/psyche/psyche.pys parse_lineœs $cCs`h|_h|_h|_tƒ}ti|d|dg7_ti dcd|7