897: #line 1193 "input_frame.ipk"
898: def data_output(self,f): return self.tangler(f,'data')
899: def c_output(self,f): return self.tangler(f,'c')
900: def cpp_output(self,f): return self.tangler(f,'cpp')
901: def python_output(self,f): return self.tangler(f,'python')
902: def perl_output(self,f): return self.tangler(f,'perl')
903:
904:
905: def interscript_output(self,f):
906: filename = self.master.tangler_directory+f
907: sink = named_file_sink(self.pass_frame,filename,self.master.tangler_prefix)
908: return self.tangler(sink,'data')
909:
910: def tangler(self,device, language=deduce, *args, **kwds):
911: "Create a tangle object from a dvice specification (either a filename or sink object"
912: if has_protocol(device, 'filename'):
913: filename = self.master.tangler_directory+str(device)
914: sink = named_file_sink(
915: self.pass_frame,
916: filename,
917: self.master.tangler_prefix)
918: elif has_protocol(device, 'sink'):
919: sink = device
920: else: raise TypeError,'tangler device argument must be string or sink'
921:
922: if language is None: language = 'data'
923: if language is deduce:
924: try:
925: splitup = string.split(sink.name,'.')
926: if len(splitup)>1:
927: extension = splitup[-1]
928: language = extension_table [extension]
929: else: language = 'data'
930: except KeyError: language = 'data'
931: except IndexError: language = 'data'
932: language = string.lower(language)
933: language = string.replace(language,'++','pp')
934: language = string.replace(language,'-','_')
935:
936: try:
937: import imp
938: import interscript.tanglers
939: file,filename,path = imp.find_module(language,interscript.tanglers.__path__)
940: tmod = imp.load_module(language,file,filename,path)
941: tglr = eval("tmod."+language+"_tangler")
942: t = tglr(sink,self.current_weaver)
943: except:
944: print 'Unable to load',language,'tangler: using data'
945: t=data_tangler(sink,self.current_weaver)
946: return t
947: