File: cache.py

package info (click to toggle)
felix 1.1.1-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,992 kB
  • ctags: 1,178
  • sloc: python: 7,260; makefile: 408; sh: 58
file content (25 lines) | stat: -rw-r--r-- 684 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#line 732 "interscript/src/source_drivers.ipk"
from interscript.drivers.sources.base import source
from interscript.drivers.sources.base import eof
import string

class cache_source(source):
  def __init__(self, name, master_frame, encoding='utf8'):
    source.__init__(self, encoding)
    self.name = name
    self.saved = ''
    macros = master_frame.get_persistent_frame('macros')
    self.list = macros.get(name,[])
    self.closed = 0

  def _raw_readline(self):
    if len(self.list)>self.lines_read:
      line = self.list[self.lines_read]
    else:
      raise eof
    self.lines_read = self.lines_read + 1
    return line

  def rewind_source(self):
    self.lines_read = 0