[Mumps2Py:] [143] added a parse_for_errors menu item (whydidn't I think of that earlier ?), and some misc. |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 143
Author: pgallot
Date: 2008-02-29 05:38:46 +0000 (Fri, 29 Feb 2008)
Log Message:
-----------
added a parse_for_errors menu item (whydidn't I think of that earlier?), and some misc. tweaking.
Modified Paths:
--------------
trunk/mumps2py_ui.pyw
Modified: trunk/mumps2py_ui.pyw
===================================================================
--- trunk/mumps2py_ui.pyw 2008-02-29 05:36:50 UTC (rev 142)
+++ trunk/mumps2py_ui.pyw 2008-02-29 05:38:46 UTC (rev 143)
@@ -317,6 +317,39 @@
except mumps2py.TranslationError, err:
self.message(err.error_msg(), "Translation Error")
+ def parse_for_errors(self):
+ """identify all modules that trigger a ParseError"""
+ if not self.modules:
+ return
+ error_list = []
+ f_name = self.modules[0].input_file
+ input_file = fileinput.input(f_name)
+ tstart = time.time()
+ try:
+ for modcnt, the_module in enumerate(self.modules):
+ try:
+ mumps2py.parseMumps(the_module, input_file)
+ except mumps2py.ParseError, err:
+ error_list.append((the_module.mod_name, err.error_msg()))
+
+ the_module.empty_tokenlist() # keep memory usage down
+ finally:
+ print time.time() - tstart, "seconds to parse %d routines" % \
+ modcnt
+ fileinput.close()
+
+ rpt_window = self.info_window("Errors in " + os.path.basename(f_name))
+ rpt_window.tag_configure('Fail', foreground = 'red',
+ font = ("Consolas", 18))
+ if len(error_list) == 0:
+ rpt_window.insert(END, "No parsing errors found.")
+ return
+
+ for routine, error in error_list:
+ rpt_window.insert(END, routine + "\n", 'Fail')
+ rpt_window.insert(END, error + "\n")
+
+
def parseuntilmodule(self, popup):
"""analyze the tokens up until the module specified by popup"""
mod_name = self.entry_val.get()
@@ -364,7 +397,7 @@
analysis = [(v, k) for k, v in toks.items()]
analysis.sort(reverse = True)
- analysis_window = self.info_window()
+ analysis_window = self.info_window("Token type frequency count")
for count, toktype_key in analysis:
analysis_window.insert(END, "%s: %d\n" % (toktype_key, count))
@@ -455,20 +488,20 @@
mumps2py_test.run_regression_tests()
result_file = open("test_results.txt", "r")
- results_window = self.info_window()
- results_window.tag_configure('Pass', foreground = 'green',
- font = ("Consolas", 14))
- results_window.tag_configure('Fail', foreground = 'red',
- font = ("Consolas", 18))
+ rpt_window = self.info_window("Regression Test results")
+ rpt_window.tag_configure('Pass', foreground = 'green',
+ font = ("Consolas", 14))
+ rpt_window.tag_configure('Fail', foreground = 'red',
+ font = ("Consolas", 18))
for line in result_file:
result = re.search("Pass|Fail", line)
if result:
- results_window.insert(END, line[:result.start()])
- results_window.insert(END, line[result.start():result.end()], \
- result.group())
- results_window.insert(END, line[result.end():])
+ rpt_window.insert(END, line[:result.start()])
+ rpt_window.insert(END, line[result.start():result.end()], \
+ result.group())
+ rpt_window.insert(END, line[result.end():])
else:
- results_window.insert(END, line)
+ rpt_window.insert(END, line)
def add_regr_test(self):
""" adds a file to the regression test suite."""
@@ -511,6 +544,9 @@
underline = 6, command = \
(lambda s = self: s.parse_all()))
parse_btn.menu.add('separator')
+ parse_btn.menu.add_command( label = "scan for errors", \
+ underline = 1, command = \
+ (lambda s = self: s.parse_for_errors()))
parse_btn.menu.add_command( label = "Analyze tokens", \
underline = 1, command = \
(lambda s = self: s.parse_analyze_tokens()))