E5XML/TemplatesWriter.py

changeset 412
569efd7f2716
parent 96
9624a110667d
child 584
b5d4c116952a
equal deleted inserted replaced
411:99409cddaaa9 412:569efd7f2716
30 """ 30 """
31 Public method to write the XML to the file. 31 Public method to write the XML to the file.
32 """ 32 """
33 XMLWriterBase.writeXML(self) 33 XMLWriterBase.writeXML(self)
34 34
35 self._write('<!DOCTYPE Templates SYSTEM "Templates-%s.dtd">' % \ 35 self._write('<!DOCTYPE Templates SYSTEM "Templates-{0}.dtd">'.format(
36 templatesFileFormatVersion) 36 templatesFileFormatVersion))
37 37
38 # add some generation comments 38 # add some generation comments
39 self._write("<!-- eric5 templates file -->") 39 self._write("<!-- eric5 templates file -->")
40 self._write("<!-- Saved: %s -->" % time.strftime('%Y-%m-%d, %H:%M:%S')) 40 self._write("<!-- Saved: {0} -->".format(time.strftime('%Y-%m-%d, %H:%M:%S')))
41 41
42 # add the main tag 42 # add the main tag
43 self._write('<Templates version="%s">' % templatesFileFormatVersion) 43 self._write('<Templates version="{0}">'.format(templatesFileFormatVersion))
44 44
45 # do the template groups 45 # do the template groups
46 groups = self.templatesViewer.getAllGroups() 46 groups = self.templatesViewer.getAllGroups()
47 for group in groups: 47 for group in groups:
48 self._write(' <TemplateGroup name="%s" language="%s">' % \ 48 self._write(' <TemplateGroup name="{0}" language="{1}">'.format(
49 (group.getName(), group.getLanguage())) 49 group.getName(), group.getLanguage()))
50 # do the templates 50 # do the templates
51 templates = group.getAllEntries() 51 templates = group.getAllEntries()
52 for template in templates: 52 for template in templates:
53 self._write(' <Template name="%s">' % \ 53 self._write(' <Template name="{0}">'.format(
54 self.escape(template.getName(), True)) 54 self.escape(template.getName(), True)))
55 self._write(' <TemplateDescription>%s</TemplateDescription>' % \ 55 self._write(' <TemplateDescription>{0}</TemplateDescription>'.format(
56 self.escape("%s" % template.getDescription())) 56 self.escape("{0}".format(template.getDescription()))))
57 self._write(' <TemplateText>%s</TemplateText>' % \ 57 self._write(' <TemplateText>{0}</TemplateText>'.format(
58 self.escape("%s" % template.getTemplateText())) 58 self.escape("{0}".format(template.getTemplateText()))))
59 self._write(' </Template>') 59 self._write(' </Template>')
60 self._write(' </TemplateGroup>') 60 self._write(' </TemplateGroup>')
61 61
62 self._write('</Templates>', newline = False) 62 self._write('</Templates>', newline = False)

eric ide

mercurial