E5XML/TemplatesWriter.py

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

eric ide

mercurial