12 import time |
12 import time |
13 |
13 |
14 from E5Gui.E5Application import e5App |
14 from E5Gui.E5Application import e5App |
15 |
15 |
16 from .XMLStreamWriterBase import XMLStreamWriterBase |
16 from .XMLStreamWriterBase import XMLStreamWriterBase |
17 from .Config import projectFileFormatVersion, projectFileFormatVersionAlt |
17 from .Config import projectFileFormatVersion, projectFileFormatVersionProto, \ |
|
18 projectFileFormatVersionAlt |
18 |
19 |
19 import Preferences |
20 import Preferences |
20 import Utilities |
21 import Utilities |
21 |
22 |
22 |
23 |
23 class ProjectWriter(XMLStreamWriterBase): |
24 class ProjectWriter(XMLStreamWriterBase): |
24 """ |
25 """ |
25 Class implementing the writer class for writing an XML project file. |
26 Class implementing the writer class for writing an XML project file. |
26 """ |
27 """ |
27 # TODO: add 'make' support |
|
28 def __init__(self, device, projectName): |
28 def __init__(self, device, projectName): |
29 """ |
29 """ |
30 Constructor |
30 Constructor |
31 |
31 |
32 @param device reference to the I/O device to write to (QIODevice) |
32 @param device reference to the I/O device to write to (QIODevice) |
41 """ |
41 """ |
42 Public method to write the XML to the file. |
42 Public method to write the XML to the file. |
43 """ |
43 """ |
44 XMLStreamWriterBase.writeXML(self) |
44 XMLStreamWriterBase.writeXML(self) |
45 |
45 |
46 if self.pdata["PROTOCOLS"]: |
46 if not e5App().getObject("Project").hasDefaultMakeParameters(): |
47 fileFormatVersion = projectFileFormatVersion |
47 fileFormatVersion = projectFileFormatVersion |
|
48 elif self.pdata["PROTOCOLS"]: |
|
49 fileFormatVersion = projectFileFormatVersionProto |
48 else: |
50 else: |
49 fileFormatVersion = projectFileFormatVersionAlt |
51 fileFormatVersion = projectFileFormatVersionAlt |
50 |
52 |
51 self.writeDTD('<!DOCTYPE Project SYSTEM "Project-{0}.dtd">'.format( |
53 self.writeDTD('<!DOCTYPE Project SYSTEM "Project-{0}.dtd">'.format( |
52 fileFormatVersion)) |
54 fileFormatVersion)) |
213 self.writeEmptyElement("LexerAssociation") |
215 self.writeEmptyElement("LexerAssociation") |
214 self.writeAttribute("pattern", pattern) |
216 self.writeAttribute("pattern", pattern) |
215 self.writeAttribute("lexer", lexer) |
217 self.writeAttribute("lexer", lexer) |
216 self.writeEndElement() |
218 self.writeEndElement() |
217 |
219 |
|
220 # do the 'make' parameters |
|
221 if not e5App().getObject("Project").hasDefaultMakeParameters(): |
|
222 self.writeStartElement("Make") |
|
223 self.writeBasics("MakeParameters", self.pdata["MAKEPARAMS"]) |
|
224 self.writeEndElement() |
|
225 |
218 # do the extra project data stuff |
226 # do the extra project data stuff |
219 if len(self.pdata["PROJECTTYPESPECIFICDATA"]): |
227 if len(self.pdata["PROJECTTYPESPECIFICDATA"]): |
220 self.writeStartElement("ProjectTypeSpecific") |
228 self.writeStartElement("ProjectTypeSpecific") |
221 if self.pdata["PROJECTTYPESPECIFICDATA"]: |
229 if self.pdata["PROJECTTYPESPECIFICDATA"]: |
222 self.writeBasics( |
230 self.writeBasics( |