[Mumps2Py:] [160] added option for MRT files having the same structure as Vista. rtn but without a header, so the routines start at line 1 instead of line 3 .

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Revision: 160
Author:   pgallot
Date:     2008-03-08 20:28:10 +0000 (Sat, 08 Mar 2008)

Log Message:
-----------
added option for MRT files having the same structure as Vista.rtn but without a header, so the routines start at line 1 instead of line 3.

Modified Paths:
--------------
    trunk/mumps2py/mumps_module.py


Modified: trunk/mumps2py/mumps_module.py
===================================================================
--- trunk/mumps2py/mumps_module.py	2008-03-08 14:30:02 UTC (rev 159)
+++ trunk/mumps2py/mumps_module.py	2008-03-08 20:28:10 UTC (rev 160)
@@ -87,12 +87,12 @@
         self.filter_in_patterns.append ( re.compile(in_re_expr))
 
     
-def parse_cache_routines(inputfile, outputdir):
+def parse_cache_routines(inputfile, outputdir, startline = 3):
     """parseForModules returns a list of MRoutine objects from a file
 in Cache Format, assuming that each Mumps module begins
 with a line containing modulename^INT^"""
     modules = []
-    lastmodline = 2
+    lastmodline = startline - 1
     oldmodname = None
 
     modpattern = re.compile(r"\^INT\^")
@@ -100,7 +100,7 @@
 
     for line in fileinput.input(inputfile):
         lineno = fileinput.lineno()
-        if lineno < 3:
+        if lineno < startline:
             continue
 
         if modpattern.search(line):
@@ -118,13 +118,13 @@
     fileinput.close()
     return modules                  
 
-def parse_astextroutines(inputfile, outputdir):
+def parse_astextroutines(inputfile, outputdir, startline = 3):
     """returns a list of MRoutine objects from a file which has
 each routine separated by a blank line and the routine name given
 on its own line before the routine body."""
 
     modules = []
-    lastmodline = 2
+    lastmodline = startline - 1
     oldmodname = None
     modpattern = re.compile(r"(?P<name>[%A-Za-z0-9][A-Za-z0-9]*)\s*$")
     print "parse_astextroutines"
@@ -134,7 +134,7 @@
     
     for line in fileinput.input(inputfile):
         lineno = fileinput.lineno()
-        if lineno < 3:
+        if lineno < startline:
             continue
 
         if endpattern.match(line):
@@ -191,6 +191,8 @@
         return parse_astextroutines(inputfile, outputdir)
     else:
         outputname, extension = os.path.splitext(inputfile)
+        if extension and extension == ".mrt":
+            return parse_astextroutines(inputfile, outputdir, 1)
         if extension and extension == ".m2p":
             return parse_from_m2p_cfg(inputfile)
         else:


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/