E5XML/TemplatesWriter.py

changeset 2992
dbdf27746da5
parent 2302
f29e9405c851
child 3057
10516539f238
child 3160
209a07d7e401
equal deleted inserted replaced
2991:226481ff40d1 2992:dbdf27746da5
20 def __init__(self, device, templatesViewer): 20 def __init__(self, device, templatesViewer):
21 """ 21 """
22 Constructor 22 Constructor
23 23
24 @param device reference to the I/O device to write to (QIODevice) 24 @param device reference to the I/O device to write to (QIODevice)
25 @param templatesViewer reference to the templates viewer object (TemplateViewer) 25 @param templatesViewer reference to the templates viewer object
26 (TemplateViewer)
26 """ 27 """
27 XMLStreamWriterBase.__init__(self, device) 28 XMLStreamWriterBase.__init__(self, device)
28 29
29 self.templatesViewer = templatesViewer 30 self.templatesViewer = templatesViewer
30 31
37 self.writeDTD('<!DOCTYPE Templates SYSTEM "Templates-{0}.dtd">'.format( 38 self.writeDTD('<!DOCTYPE Templates SYSTEM "Templates-{0}.dtd">'.format(
38 templatesFileFormatVersion)) 39 templatesFileFormatVersion))
39 40
40 # add some generation comments 41 # add some generation comments
41 self.writeComment(" eric5 templates file ") 42 self.writeComment(" eric5 templates file ")
42 self.writeComment(" Saved: {0} ".format(time.strftime('%Y-%m-%d, %H:%M:%S'))) 43 self.writeComment(
44 " Saved: {0} ".format(time.strftime('%Y-%m-%d, %H:%M:%S')))
43 45
44 # add the main tag 46 # add the main tag
45 self.writeStartElement("Templates") 47 self.writeStartElement("Templates")
46 self.writeAttribute("version", templatesFileFormatVersion) 48 self.writeAttribute("version", templatesFileFormatVersion)
47 49
54 # do the templates 56 # do the templates
55 templates = group.getAllEntries() 57 templates = group.getAllEntries()
56 for template in templates: 58 for template in templates:
57 self.writeStartElement("Template") 59 self.writeStartElement("Template")
58 self.writeAttribute("name", template.getName()) 60 self.writeAttribute("name", template.getName())
59 self.writeTextElement("TemplateDescription", template.getDescription()) 61 self.writeTextElement(
60 self.writeTextElement("TemplateText", template.getTemplateText()) 62 "TemplateDescription", template.getDescription())
63 self.writeTextElement(
64 "TemplateText", template.getTemplateText())
61 self.writeEndElement() 65 self.writeEndElement()
62 self.writeEndElement() 66 self.writeEndElement()
63 67
64 self.writeEndElement() 68 self.writeEndElement()
65 self.writeEndDocument() 69 self.writeEndDocument()

eric ide

mercurial