[GRASS-SVN] r65199 - in grass/trunk/gui/wxpython: . core
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri May 8 19:53:07 PDT 2015
Author: wenzeslaus
Date: 2015-05-08 19:53:07 -0700 (Fri, 08 May 2015)
New Revision: 65199
Modified:
grass/trunk/gui/wxpython/Makefile
grass/trunk/gui/wxpython/core/toolboxes.py
Log:
wxGUI/toolboxes: try to read XMLs after writing them
This is just to be sure they are basically OK.
We cannot use DTD validation beacause it is not available in standard Python and even if we would use lxml, if available, we would have to do the same for writing to write down DOCTYPE line.
Modified: grass/trunk/gui/wxpython/Makefile
===================================================================
--- grass/trunk/gui/wxpython/Makefile 2015-05-08 21:17:05 UTC (rev 65198)
+++ grass/trunk/gui/wxpython/Makefile 2015-05-09 02:53:07 UTC (rev 65199)
@@ -38,9 +38,11 @@
xml/menudata.xml: core/toolboxes.py
$(call run_grass,$(PYTHON) $< > $@)
+ $(call run_grass,$(PYTHON) $< "validate" $@)
xml/module_tree_menudata.xml: core/toolboxes.py
$(call run_grass,$(PYTHON) $< "module_tree" > $@)
+ $(call run_grass,$(PYTHON) $< "validate" $@)
menustrings.py: core/menutree.py $(DSTDIR)/xml/menudata.xml $(DSTDIR)/xml/module_tree_menudata.xml $(DSTDIR)/xml/menudata_modeler.xml $(DSTDIR)/xml/menudata_psmap.xml
@echo "# This is a generated file.\n" > $@
@@ -52,6 +54,7 @@
$(DSTDIR)/xml/module_items.xml: tools/build_modules_xml.py
@echo "Generating interface description for all modules..."
$(call run_grass,$(PYTHON) $< > $@)
+ $(call run_grass,$(PYTHON) $< "validate" $@)
$(PYDSTDIRS): %: | $(DSTDIR)
$(MKDIR) $@
Modified: grass/trunk/gui/wxpython/core/toolboxes.py
===================================================================
--- grass/trunk/gui/wxpython/core/toolboxes.py 2015-05-08 21:17:05 UTC (rev 65198)
+++ grass/trunk/gui/wxpython/core/toolboxes.py 2015-05-09 02:53:07 UTC (rev 65199)
@@ -827,6 +827,16 @@
return 0
+def validate_file(filename):
+ try:
+ etree.parse(filename)
+ except ETREE_EXCEPTIONS as error:
+ print "XML file <{name}> is not well formed: {error}".format(
+ name=filename, error=error)
+ return 1
+ return 0
+
+
def main():
"""Converts the toolboxes files on standard paths to the menudata file
@@ -852,4 +862,6 @@
sys.exit(doc_test())
elif sys.argv[1] == 'test':
sys.exit(module_test())
+ elif sys.argv[1] == 'validate':
+ sys.exit(validate_file(sys.argv[2]))
sys.exit(main())
More information about the grass-commit
mailing list