-class Feta_file(File):
- """Read Feta metrics from a metafont log-file."""
-
- def include_scan (self, line):
- include_pos = include_re.search (line)
- while include_pos <> -1:
- self.dependencies.append (include_re.group (1))
-
- line = line[include_pos + 1:]
- include_pos = include_re.search (line)
-
- def read_autometricline(self):
- line = ''
- while end_autometric_re.search(line) == -1 and not self.eof():
- suf = File.readline(self)
- self.include_scan (suf)
- if begin_autometric_re.search(line) == -1:
- line = ''
- line = line + regsub.sub('\n','', suf)
- line = regsub.sub('\r','', line)
-
- if self.eof():
- return ''
-
- return line;
- def readline(self):
- """return what is enclosed in one @{ @} pair"""
- line = '';
- while autometric_re.search(line) == -1 and not self.eof():
- line = self.read_autometricline()
-
- if self.eof():
- return '';
-
- return autometric_re.group(1);
- def __init__(self, nm):
- File.__init__(self, nm)
- self.dependencies = []
- def do_file(infile_nm):
- infile = readline();
-
-#
-# FIXME: should parse output for {} to do indenting.
-#
-class Indentable_file(File):
- """Output file with support for indentation"""
- def __init__(self,nm, mode):
- File.__init__(self,nm,mode)
- self.current_indent_ = 0
- self.delta_indent_ = 4
- def writeline (self, str):
- File.write(self, str)
- def writeeol(self):
- File.write(self, '\n')
- File.write(self, ' '* self.current_indent_)
-
- def indent(self):
- self.current_indent_ = self.delta_indent_ + self.current_indent_;
- def dedent(self):
- self.current_indent_ = self.current_indent_ - self.delta_indent_;
- if self.current_indent_ < 0:
- raise 'Nesting!'
-
- def write(self, str):
- lines = split(str, '\n')
- for l in lines[:-1]:
- self.writeline(l)
- self.writeeol()
- self.writeline (lines[-1])
-
-class Afm_file (File):
+print re
+
+def read_log_file (fn):
+ str = gulp_file (fn)
+ str = re.sub ('\n', '', str)
+ str = re.sub ('[\t ]+', ' ', str)
+
+ deps = []
+ autolines = []
+ def include_func (match, d = deps):
+ d.append (match.group (1))
+ return ''
+
+ def auto_func (match, a = autolines):
+ a.append (match.group (1))
+ return ''
+
+ str = re.sub ('\(([a-zA-Z_0-9-]+\.mf)', include_func, str)
+ str = re.sub ('@{(.*?)@}', auto_func, str)
+
+ return (autolines, deps)
+
+
+class Afm_file: