[Mumps2Py:] [170] added to the error report the ability to extract the problem routines to another file for easier debugging . |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 170
Author: pgallot
Date: 2008-03-12 15:40:20 +0000 (Wed, 12 Mar 2008)
Log Message:
-----------
added to the error report the ability to extract the problem routines to another file for easier debugging.
Modified Paths:
--------------
trunk/mumps2py_ui.pyw
Modified: trunk/mumps2py_ui.pyw
===================================================================
--- trunk/mumps2py_ui.pyw 2008-03-12 13:19:44 UTC (rev 169)
+++ trunk/mumps2py_ui.pyw 2008-03-12 15:40:20 UTC (rev 170)
@@ -425,6 +425,47 @@
self.message(err.error_msg(), "Translation Error")
self.busy(False)
+ def extract_mods(self, the_mod_list):
+ """extract the given list of routines from the current file."""
+ f_name = self.current_file
+ f_dir = os.path.abspath(f_name)
+ suggest_name = "%s_errors.mrt" % (os.path.splitext(f_name)[0])
+ dlg_title = "save these extracted routines to..."
+
+ extract_fname = tkFileDialog.asksaveasfilename( \
+ parent = self.root, initialfile = suggest_name,
+ initialdir = f_dir, title = dlg_title)
+
+ if not extract_fname:
+ return
+
+ extract_file = open(extract_fname,"w")
+ routine = the_mod_list.pop(0)
+ input_file = fileinput.input(routine.input_file)
+
+ for line in input_file:
+ lineno = fileinput.lineno()
+
+ if lineno < routine.start:
+ continue
+ elif lineno == routine.start:
+ extract_file.write(routine.mod_name + '\n')
+
+ if routine.end != -1 and lineno > routine.end:
+ extract_file.write('\n')
+ if the_mod_list:
+ routine = the_mod_list.pop(0)
+ continue
+ else:
+ break
+
+ extract_file.write(line)
+
+ extract_file.write("\n\n%s" % ("#########\n" * 4))
+ extract_file.close()
+ fileinput.close()
+
+
def parse_for_errors(self):
"""identify all modules that trigger a ParseError"""
if not self.modules:
@@ -439,7 +480,7 @@
try:
mumps2py.parse_routine(the_module, input_file)
except mumps2py.ParseError, err:
- error_list.append((the_module.mod_name, err.error_msg()))
+ error_list.append((the_module, err.error_msg()))
the_module.empty_tokenlist() # keep memory usage down
finally:
@@ -452,8 +493,15 @@
if len(error_list) == 0:
rpt_window.insert(END, "No parsing errors found.")
return
+
+ routines_list = [routine for routine, err in error_list]
+ rpt_window.tag_configure("_extract_", foreground = 'blue')
+ rpt_window.tag_bind("_extract_", '<1>', lambda e, s = self, \
+ l = routines_list: s.extract_mods(l))
+ rpt_window.insert(END, "**extract these routines**\n\n", "_extract_")
- for r_name, error in error_list:
+ for the_module, error in error_list:
+ r_name = the_module.mod_name
blacklist = r_name + '_bl'
rpt_window.tag_configure(r_name, foreground = 'red',
font = ("Consolas", 18))