1: #line 89 "tanglers.ipk"
2:
3:
4:
5: class tangler_base:
6: __class_protocols__ = ['tangler']
7: def __init__(self,sink,weaver):
8: self.sink = sink
9: self.weaver = weaver
10: self.inhibit_sref = 0
11: if weaver:
12: self.pass_frame = weaver.pass_frame
13: self.master = self.pass_frame.master
14: self.process = self.master.process
15: if 'tanglers' in self.process.trace:
16: self.process.acquire_object(self, 'TANGLER')
17: else:
18: self.pass_frame = None
19: self.master = None
20: self.process = None
21: self.language = 'data'
22:
23: def get_language(self): return self.language
24:
25: def write_comment(self,line):
26: pass
27:
28: def _writeline(self,data):
29: self.sink.writeline(data)
30:
31: def _write_and_echo(self,data):
32: self._writeline(data)
33: self.weaver.echotangle(self.sink.lines_written,data)
34:
35: def _handle_sref(self, file, count, inhibit_sref):
36: if not inhibit_sref and not self.inhibit_sref:
37: if (file != self.sink.last_source_file or
38: count != self.sink.last_source_count+1 or
39: self.sink.last_inhibit_sref):
40: self.start_section(file,count)
41: self.sink.last_inhibit_sref = 0
42: else:
43: self.sink.last_inhibit_sref = 1
44: self.sink.last_source_file = file
45: self.sink.last_source_count = count
46:
47: def writeline(self,data,file,count, inhibit_sref=0):
48: self._handle_sref(file,count,inhibit_sref)
49: self._write_and_echo(data)
50:
51: def start_section(self,file,count): pass
52:
53: def __del__(self):
54: if self.process and 'tanglers' in self.process.trace:
55: self.process.release_object(self)
56:
57:
58:
59:
60: