# HG changeset patch # User Edouard Tisserant # Date 1613984916 -3600 # Node ID 76c0c0a524c9e0c3eb7ed261f29a687eb3fdc30c # Parent 99ce78ddd353db67ee33c8d0c9f9ff213f4a604a SVGHMI: display progress in IDE console while building diff -r 99ce78ddd353 -r 76c0c0a524c9 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Sun Feb 21 21:38:44 2021 +0100 +++ b/svghmi/gen_index_xhtml.xslt Mon Feb 22 10:08:36 2021 +0100 @@ -19,6 +19,7 @@ + /* @@ -61,6 +62,7 @@ + @@ -278,6 +280,7 @@ + /* @@ -302,10 +305,12 @@ + + /* @@ -332,6 +337,7 @@ + @@ -407,6 +413,7 @@ + /* @@ -423,6 +430,7 @@ + @@ -482,6 +490,7 @@ + /* @@ -512,6 +521,7 @@ + @@ -627,6 +637,7 @@ + /* @@ -644,10 +655,12 @@ + + /* @@ -676,6 +689,7 @@ + @@ -895,6 +909,7 @@ + /* @@ -911,9 +926,11 @@ + + /* @@ -940,6 +957,7 @@ + @@ -965,6 +983,7 @@ + /* @@ -1027,6 +1046,7 @@ + @@ -1129,6 +1149,7 @@ + /* @@ -1272,9 +1293,11 @@ + + /* @@ -1669,11 +1692,13 @@ + + /* @@ -1686,6 +1711,7 @@ + class @@ -1703,6 +1729,7 @@ + /* @@ -1718,6 +1745,7 @@ + @@ -2967,6 +2995,7 @@ + /* @@ -3443,6 +3472,7 @@ + function numb_event(e) { @@ -5153,6 +5183,7 @@ + /* @@ -5179,9 +5210,11 @@ + + /* @@ -5214,6 +5247,7 @@ + class KeypadWidget extends Widget{ diff -r 99ce78ddd353 -r 76c0c0a524c9 svghmi/gen_index_xhtml.ysl2 --- a/svghmi/gen_index_xhtml.ysl2 Sun Feb 21 21:38:44 2021 +0100 +++ b/svghmi/gen_index_xhtml.ysl2 Mon Feb 22 10:08:36 2021 +0100 @@ -7,11 +7,13 @@ decl emit(*name) alias - { *name; template *name { + const "_unused", "ns:ProgressStart(name())"; | | /* «local-name()» */ | content; | + const "__unused", "ns:ProgressEnd(name())"; } }; diff -r 99ce78ddd353 -r 76c0c0a524c9 svghmi/svghmi.py --- a/svghmi/svghmi.py Sun Feb 21 21:38:44 2021 +0100 +++ b/svghmi/svghmi.py Mon Feb 22 10:08:36 2021 +0100 @@ -14,6 +14,7 @@ import hashlib import weakref import shlex +import time import wx import wx.dataview as dv @@ -544,6 +545,18 @@ return TranslationToEtree(langs,translated_messages) + times = {} + def ProgressStart(self, _context, message): + t = time.time() + s = str(message) + self.times[s] = t + + def ProgressEnd(self, _context, message): + t = time.time() + s = str(message) + self.GetCTRoot().logger.write(" %s: %.3f\n"%(message, t - self.times[s])) + self.times[s] = t + def CTNGenerate_C(self, buildpath, locations): location_str = "_".join(map(str, self.GetCurrentLocation())) @@ -558,18 +571,26 @@ target_path = os.path.join(self._getBuildPath(), target_fname) target_file = open(target_path, 'wb') + self.GetCTRoot().logger.write("SVGHMI:\n") + if os.path.exists(svgfile): # TODO : move to __init__ transform = XSLTransform(os.path.join(ScriptDirectory, "gen_index_xhtml.xslt"), [("GetSVGGeometry", lambda *_ignored:self.GetSVGGeometry()), ("GetHMITree", lambda *_ignored:self.GetHMITree()), - ("GetTranslations", self.GetTranslations)]) - + ("GetTranslations", self.GetTranslations), + ("ProgressStart", self.ProgressStart), + ("ProgressEnd", self.ProgressEnd)]) + + + t = time.time() # load svg as a DOM with Etree svgdom = etree.parse(svgfile) + self.GetCTRoot().logger.write(" Source SVG parsing: %.3f\n"%(time.time()-t)) + # call xslt transform on Inkscape's SVG to generate XHTML try: result = transform.transform(svgdom)