542 langs,translated_messages = MatchTranslations(translations, messages, |
543 langs,translated_messages = MatchTranslations(translations, messages, |
543 errcallback=self.GetCTRoot().logger.write_warning) |
544 errcallback=self.GetCTRoot().logger.write_warning) |
544 |
545 |
545 return TranslationToEtree(langs,translated_messages) |
546 return TranslationToEtree(langs,translated_messages) |
546 |
547 |
|
548 times = {} |
|
549 def ProgressStart(self, _context, message): |
|
550 t = time.time() |
|
551 s = str(message) |
|
552 self.times[s] = t |
|
553 |
|
554 def ProgressEnd(self, _context, message): |
|
555 t = time.time() |
|
556 s = str(message) |
|
557 self.GetCTRoot().logger.write(" %s: %.3f\n"%(message, t - self.times[s])) |
|
558 self.times[s] = t |
|
559 |
547 def CTNGenerate_C(self, buildpath, locations): |
560 def CTNGenerate_C(self, buildpath, locations): |
548 |
561 |
549 location_str = "_".join(map(str, self.GetCurrentLocation())) |
562 location_str = "_".join(map(str, self.GetCurrentLocation())) |
550 view_name = self.BaseParams.getName() |
563 view_name = self.BaseParams.getName() |
551 |
564 |
555 |
568 |
556 target_fname = "svghmi_"+location_str+".xhtml" |
569 target_fname = "svghmi_"+location_str+".xhtml" |
557 |
570 |
558 target_path = os.path.join(self._getBuildPath(), target_fname) |
571 target_path = os.path.join(self._getBuildPath(), target_fname) |
559 target_file = open(target_path, 'wb') |
572 target_file = open(target_path, 'wb') |
|
573 |
|
574 self.GetCTRoot().logger.write("SVGHMI:\n") |
560 |
575 |
561 if os.path.exists(svgfile): |
576 if os.path.exists(svgfile): |
562 |
577 |
563 # TODO : move to __init__ |
578 # TODO : move to __init__ |
564 transform = XSLTransform(os.path.join(ScriptDirectory, "gen_index_xhtml.xslt"), |
579 transform = XSLTransform(os.path.join(ScriptDirectory, "gen_index_xhtml.xslt"), |
565 [("GetSVGGeometry", lambda *_ignored:self.GetSVGGeometry()), |
580 [("GetSVGGeometry", lambda *_ignored:self.GetSVGGeometry()), |
566 ("GetHMITree", lambda *_ignored:self.GetHMITree()), |
581 ("GetHMITree", lambda *_ignored:self.GetHMITree()), |
567 ("GetTranslations", self.GetTranslations)]) |
582 ("GetTranslations", self.GetTranslations), |
568 |
583 ("ProgressStart", self.ProgressStart), |
|
584 ("ProgressEnd", self.ProgressEnd)]) |
|
585 |
|
586 |
|
587 t = time.time() |
569 |
588 |
570 # load svg as a DOM with Etree |
589 # load svg as a DOM with Etree |
571 svgdom = etree.parse(svgfile) |
590 svgdom = etree.parse(svgfile) |
|
591 |
|
592 self.GetCTRoot().logger.write(" Source SVG parsing: %.3f\n"%(time.time()-t)) |
572 |
593 |
573 # call xslt transform on Inkscape's SVG to generate XHTML |
594 # call xslt transform on Inkscape's SVG to generate XHTML |
574 try: |
595 try: |
575 result = transform.transform(svgdom) |
596 result = transform.transform(svgdom) |
576 except XSLTApplyError as e: |
597 except XSLTApplyError as e: |