diff --git a/scripts/bench.py b/scripts/bench.py index 99bf2376..113f986d 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -362,17 +362,18 @@ def compile(bench_paths, **args): # write generated bench source if 'output' in args: with openio(args['output'], 'w') as f: - _write = f.write - def write(s): - f.lineno += s.count('\n') - _write(s) - def writeln(s=''): - f.lineno += s.count('\n') + 1 - _write(s) - _write('\n') + # some helpful file functions f.lineno = 1 - f.write = write - f.writeln = writeln + f.write_ = f.write + def write(self, s): + self.lineno += s.count('\n') + self.write_(s) + f.write = write.__get__(f) + def writeln(self, s=''): + self.lineno += s.count('\n') + 1 + self.write_(s) + self.write_('\n') + f.writeln = writeln.__get__(f) f.writeln("// Generated by %s:" % sys.argv[0]) f.writeln("//") diff --git a/scripts/codemap.py b/scripts/codemap.py index d026a4c9..66ae1ed3 100755 --- a/scripts/codemap.py +++ b/scripts/codemap.py @@ -951,11 +951,11 @@ def main_(ring, paths, *, label=False, no_label=False, **args): - # give ring an writeln function - def writeln(s=''): - ring.write(s) - ring.write('\n') - ring.writeln = writeln + # give ring a writeln function + def writeln(self, s=''): + self.write(s) + self.write('\n') + ring.writeln = writeln.__get__(ring) # figure out what color should be if color == 'auto': diff --git a/scripts/codemapsvg.py b/scripts/codemapsvg.py index 110aad81..9be108e3 100755 --- a/scripts/codemapsvg.py +++ b/scripts/codemapsvg.py @@ -1174,10 +1174,10 @@ def main(paths, output, *, # create svg file with openio(output, 'w') as f: - def writeln(s=''): - f.write(s) - f.write('\n') - f.writeln = writeln + def writeln(self, s=''): + self.write(s) + self.write('\n') + f.writeln = writeln.__get__(f) # yes this is svg f.write('