6.13.10.2.12. Untangle

This command is used inside an interscript tangler to put an external file into a .pak archive. It writes out a 'select' (see select) command, and then the file, with leading @ characters converted to two @ characters. Use it like this:
  @select(archive)
  @untangle('fred.pak')
  @untangle('joe.pak')
This mechanism is required to support include files, since a top level document is incomplete otherwise.

Note that the inserted code is not woven! In fact, the tangler never sees it, it simply supplies the sink object.

Start python section to interscript/frames/inputf.py[17 /40 ] Next Prev Last
   512: #line 718 "input_frame.ipk"
   513:   def untangle(self,name):
   514:     if not self.current_tangler:
   515:       raise 'untangle without active tangler'
   516:     f = open(name)
   517:     data = f.readlines()
   518:     f.close()
   519:     self.current_tangler.sink.writeline('@select(output("'+name+'"))')
   520:     for line in data:
   521:       l = string.rstrip(line)
   522:       if len(l):
   523:         if l[0]=='@': l = '@'+l
   524:       self.inpt.tangler.sink.writeline(l)
   525:     self.current_tangler.sink.writeline('@select(None)')
   526:     self.current_tangler.weaver.begin_small()
   527:     self.current_tangler.weaver.writeline('Included '+name+', '+str(len(data))+' lines.')
   528:     self.current_tangler.weaver.end_small()
   529:     self.current_tangler.weaver.line_break()
   530: 
End python section to interscript/frames/inputf.py[17]