6.19.10.2.13. 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[18 /42 ] Next Prev First Last
   628: #line 839 "input_frame.ipk"
   629:   def untangle(self,name):
   630:     """Wrap an external file up as an interscript package, the wrapped
   631:     file is written to the current tangler."""
   632:     if not self.current_tangler:
   633:       raise 'untangle without active tangler'
   634:     f = open(name)
   635:     data = f.readlines()
   636:     f.close()
   637:     self.current_tangler.sink.writeline('@select(output("'+name+'"))')
   638:     for line in data:
   639:       l = string.rstrip(line)
   640:       if len(l):
   641:         if l[0]=='@': l = '@'+l
   642:       self.inpt.tangler.sink.writeline(l)
   643:     self.current_tangler.sink.writeline('@select(None)')
   644:     self.current_tangler.weaver.begin_small()
   645:     self.current_tangler.weaver.writeline('Included '+name+', '+str(len(data))+' lines.')
   646:     self.current_tangler.weaver.end_small()
   647:     self.current_tangler.weaver.line_break()
   648: 
End python section to interscript/frames/inputf.py[18]