6.13.3.1. Memory Driver

The memory driver is both a source and sink and can is used as a simple form of macro. By tangling sections of code into memory, a sction can be built which is later emitted in a single block. In this sense the tangler driving the memory device is defining a macro, and its later inclusion in te source stream can be considered expanding the macro.
Start python section to interscript/drivers/storage/memory.py[1 /1 ]
     1: #line 16 "storage_drivers.ipk"
     2: from interscript.drivers.sources.base import source
     3: from interscript.drivers.sources.base import eof
     4: from interscript.drivers.sinks.base import sink_base
     5: 
     6: class memory(source,sink_base):
     7:   def __init__(self,name,**kwds):
     8:     source.__init__(self)
     9:     sink_base.__init__(self)
    10:     self.name = name
    11:     self.saved = ''
    12:     self.list = []
    13:     for k in kwds.keys():
    14:       self.k = kwds[k]
    15:     self.closed = 0
    16: 
    17:   def raw_readline(self):
    18:     if len(self.list)>self.lines_read:
    19:       line = self.list[self.lines_read]
    20:     else:
    21:       raise eof
    22:     self.lines_read = self.lines_read + 1
    23:     return line
    24: 
    25:   def raw_eol(self):
    26:     self.list.append(self.saved)
    27:     self.saved = ''
    28: 
    29:   def rewind_source(self):
    30:     self.lines_read = 0
    31: 
    32:   def raw_write(self,data):
    33:     self.saved = self.saved + data
    34: 
End python section to interscript/drivers/storage/memory.py[1]