37 """ |
37 """ |
38 Public method to write the XML to the file. |
38 Public method to write the XML to the file. |
39 """ |
39 """ |
40 XMLWriterBase.writeXML(self) |
40 XMLWriterBase.writeXML(self) |
41 |
41 |
42 self._write('<!DOCTYPE Project SYSTEM "Project-%s.dtd">' % \ |
42 self._write('<!DOCTYPE Project SYSTEM "Project-{0}.dtd">'.format( |
43 projectFileFormatVersion) |
43 projectFileFormatVersion)) |
44 |
44 |
45 # add some generation comments |
45 # add some generation comments |
46 self._write("<!-- eric5 project file for project %s -->" % self.name) |
46 self._write("<!-- eric5 project file for project {0} -->".format(self.name)) |
47 if Preferences.getProject("XMLTimestamp"): |
47 if Preferences.getProject("XMLTimestamp"): |
48 self._write("<!-- Saved: %s -->" % time.strftime('%Y-%m-%d, %H:%M:%S')) |
48 self._write("<!-- Saved: {0} -->".format(time.strftime('%Y-%m-%d, %H:%M:%S'))) |
49 self._write("<!-- Copyright (C) %s %s, %s -->" % \ |
49 self._write("<!-- Copyright (C) {0} {1}, {2} -->".format( |
50 (time.strftime('%Y'), |
50 time.strftime('%Y'), |
51 self.escape(self.pdata["AUTHOR"][0]), |
51 self.escape(self.pdata["AUTHOR"][0]), |
52 self.escape(self.pdata["EMAIL"][0]))) |
52 self.escape(self.pdata["EMAIL"][0]))) |
53 |
53 |
54 # add the main tag |
54 # add the main tag |
55 self._write('<Project version="%s">' % projectFileFormatVersion) |
55 self._write('<Project version="{0}">'.format(projectFileFormatVersion)) |
56 |
56 |
57 # do the language (used for spell checking) |
57 # do the language (used for spell checking) |
58 self._write(' <Language>%s</Language>' % self.pdata["SPELLLANGUAGE"][0]) |
58 self._write(' <Language>{0}</Language>'.format(self.pdata["SPELLLANGUAGE"][0])) |
59 if len(self.pdata["SPELLWORDS"][0]) > 0: |
59 if len(self.pdata["SPELLWORDS"][0]) > 0: |
60 self._write(" <ProjectWordList>%s</ProjectWordList>" % \ |
60 self._write(" <ProjectWordList>{0}</ProjectWordList>".format( |
61 Utilities.fromNativeSeparators(self.pdata["SPELLWORDS"][0])) |
61 Utilities.fromNativeSeparators(self.pdata["SPELLWORDS"][0]))) |
62 if len(self.pdata["SPELLEXCLUDES"][0]) > 0: |
62 if len(self.pdata["SPELLEXCLUDES"][0]) > 0: |
63 self._write(" <ProjectExcludeList>%s</ProjectExcludeList>" % \ |
63 self._write(" <ProjectExcludeList>{0}</ProjectExcludeList>".format( |
64 Utilities.fromNativeSeparators(self.pdata["SPELLEXCLUDES"][0])) |
64 Utilities.fromNativeSeparators(self.pdata["SPELLEXCLUDES"][0]))) |
65 |
65 |
66 # do the hash |
66 # do the hash |
67 self._write(' <Hash>%s</Hash>' % self.pdata["HASH"][0]) |
67 self._write(' <Hash>{0}</Hash>'.format(self.pdata["HASH"][0])) |
68 |
68 |
69 # do the programming language |
69 # do the programming language |
70 self._write(' <ProgLanguage mixed="%d">%s</ProgLanguage>' % \ |
70 self._write(' <ProgLanguage mixed="{0:d}">{1}</ProgLanguage>'.format( |
71 (self.pdata["MIXEDLANGUAGE"][0], self.pdata["PROGLANGUAGE"][0])) |
71 self.pdata["MIXEDLANGUAGE"][0], self.pdata["PROGLANGUAGE"][0])) |
72 |
72 |
73 # do the UI type |
73 # do the UI type |
74 self._write(' <ProjectType>%s</ProjectType>' % self.pdata["PROJECTTYPE"][0]) |
74 self._write(' <ProjectType>{0}</ProjectType>'.format( |
|
75 self.pdata["PROJECTTYPE"][0])) |
75 |
76 |
76 # do description |
77 # do description |
77 if self.pdata["DESCRIPTION"]: |
78 if self.pdata["DESCRIPTION"]: |
78 self._write(" <Description>%s</Description>" % \ |
79 self._write(" <Description>{0}</Description>".format( |
79 self.escape(self.encodedNewLines(self.pdata["DESCRIPTION"][0]))) |
80 self.escape(self.encodedNewLines(self.pdata["DESCRIPTION"][0])))) |
80 |
81 |
81 # do version, author and email |
82 # do version, author and email |
82 for key in ["VERSION", "AUTHOR", "EMAIL"]: |
83 for key in ["VERSION", "AUTHOR", "EMAIL"]: |
83 element = key.capitalize() |
84 element = key.capitalize() |
84 if self.pdata[key]: |
85 if self.pdata[key]: |
85 self._write(" <%s>%s</%s>" % \ |
86 self._write(" <{0}>{1}</{0}>".format( |
86 (element, self.escape(self.pdata[key][0]), element)) |
87 element, self.escape(self.pdata[key][0]))) |
87 |
88 |
88 # do the translation pattern |
89 # do the translation pattern |
89 if self.pdata["TRANSLATIONPATTERN"]: |
90 if self.pdata["TRANSLATIONPATTERN"]: |
90 self._write(" <TranslationPattern>%s</TranslationPattern>" % \ |
91 self._write(" <TranslationPattern>{0}</TranslationPattern>".format( |
91 Utilities.fromNativeSeparators(self.pdata["TRANSLATIONPATTERN"][0])) |
92 Utilities.fromNativeSeparators(self.pdata["TRANSLATIONPATTERN"][0]))) |
92 |
93 |
93 # do the binary translations path |
94 # do the binary translations path |
94 if self.pdata["TRANSLATIONSBINPATH"]: |
95 if self.pdata["TRANSLATIONSBINPATH"]: |
95 self._write(" <TranslationsBinPath>%s</TranslationsBinPath>" % \ |
96 self._write(" <TranslationsBinPath>{0}</TranslationsBinPath>".format( |
96 Utilities.fromNativeSeparators(self.pdata["TRANSLATIONSBINPATH"][0])) |
97 Utilities.fromNativeSeparators(self.pdata["TRANSLATIONSBINPATH"][0]))) |
97 |
98 |
98 # do the eol setting |
99 # do the eol setting |
99 if self.pdata["EOL"] and self.pdata["EOL"][0]: |
100 if self.pdata["EOL"] and self.pdata["EOL"][0]: |
100 self._write(' <Eol index="%d" />' % self.pdata["EOL"][0]) |
101 self._write(' <Eol index="{0:d}" />'.format(self.pdata["EOL"][0])) |
101 |
102 |
102 # do the sources |
103 # do the sources |
103 self._write(" <Sources>") |
104 self._write(" <Sources>") |
104 for name in self.pdata["SOURCES"]: |
105 for name in self.pdata["SOURCES"]: |
105 self._write(" <Source>%s</Source>" % \ |
106 self._write(" <Source>{0}</Source>".format( |
106 Utilities.fromNativeSeparators(name)) |
107 Utilities.fromNativeSeparators(name))) |
107 self._write(" </Sources>") |
108 self._write(" </Sources>") |
108 |
109 |
109 # do the forms |
110 # do the forms |
110 self._write(" <Forms>") |
111 self._write(" <Forms>") |
111 for name in self.pdata["FORMS"]: |
112 for name in self.pdata["FORMS"]: |
112 self._write(" <Form>%s</Form>" % \ |
113 self._write(" <Form>{0}</Form>".format( |
113 Utilities.fromNativeSeparators(name)) |
114 Utilities.fromNativeSeparators(name))) |
114 self._write(" </Forms>") |
115 self._write(" </Forms>") |
115 |
116 |
116 # do the translations |
117 # do the translations |
117 self._write(" <Translations>") |
118 self._write(" <Translations>") |
118 for name in self.pdata["TRANSLATIONS"]: |
119 for name in self.pdata["TRANSLATIONS"]: |
119 self._write(" <Translation>%s</Translation>" % \ |
120 self._write(" <Translation>{0}</Translation>".format( |
120 Utilities.fromNativeSeparators(name)) |
121 Utilities.fromNativeSeparators(name))) |
121 self._write(" </Translations>") |
122 self._write(" </Translations>") |
122 |
123 |
123 # do the translation exceptions |
124 # do the translation exceptions |
124 if self.pdata["TRANSLATIONEXCEPTIONS"]: |
125 if self.pdata["TRANSLATIONEXCEPTIONS"]: |
125 self._write(" <TranslationExceptions>") |
126 self._write(" <TranslationExceptions>") |
126 for name in self.pdata["TRANSLATIONEXCEPTIONS"]: |
127 for name in self.pdata["TRANSLATIONEXCEPTIONS"]: |
127 self._write(" <TranslationException>%s</TranslationException>" % \ |
128 self._write(" <TranslationException>{0}</TranslationException>".format( |
128 Utilities.fromNativeSeparators(name)) |
129 Utilities.fromNativeSeparators(name))) |
129 self._write(" </TranslationExceptions>") |
130 self._write(" </TranslationExceptions>") |
130 |
131 |
131 # do the resources |
132 # do the resources |
132 self._write(" <Resources>") |
133 self._write(" <Resources>") |
133 for name in self.pdata["RESOURCES"]: |
134 for name in self.pdata["RESOURCES"]: |
134 self._write(" <Resource>%s</Resource>" % \ |
135 self._write(" <Resource>{0}</Resource>".format( |
135 Utilities.fromNativeSeparators(name)) |
136 Utilities.fromNativeSeparators(name))) |
136 self._write(" </Resources>") |
137 self._write(" </Resources>") |
137 |
138 |
138 # do the interfaces (IDL) |
139 # do the interfaces (IDL) |
139 self._write(" <Interfaces>") |
140 self._write(" <Interfaces>") |
140 for name in self.pdata["INTERFACES"]: |
141 for name in self.pdata["INTERFACES"]: |
141 self._write(" <Interface>%s</Interface>" % \ |
142 self._write(" <Interface>{0}</Interface>".format( |
142 Utilities.fromNativeSeparators(name)) |
143 Utilities.fromNativeSeparators(name))) |
143 self._write(" </Interfaces>") |
144 self._write(" </Interfaces>") |
144 |
145 |
145 # do the others |
146 # do the others |
146 self._write(" <Others>") |
147 self._write(" <Others>") |
147 for name in self.pdata["OTHERS"]: |
148 for name in self.pdata["OTHERS"]: |
148 self._write(" <Other>%s</Other>" % \ |
149 self._write(" <Other>{0}</Other>".format( |
149 Utilities.fromNativeSeparators(name)) |
150 Utilities.fromNativeSeparators(name))) |
150 self._write(" </Others>") |
151 self._write(" </Others>") |
151 |
152 |
152 # do the main script |
153 # do the main script |
153 if self.pdata["MAINSCRIPT"]: |
154 if self.pdata["MAINSCRIPT"]: |
154 self._write(" <MainScript>%s</MainScript>" % \ |
155 self._write(" <MainScript>{0}</MainScript>".format( |
155 Utilities.fromNativeSeparators(self.pdata["MAINSCRIPT"][0])) |
156 Utilities.fromNativeSeparators(self.pdata["MAINSCRIPT"][0]))) |
156 |
157 |
157 # do the vcs stuff |
158 # do the vcs stuff |
158 self._write(" <Vcs>") |
159 self._write(" <Vcs>") |
159 if self.pdata["VCS"]: |
160 if self.pdata["VCS"]: |
160 self._write(" <VcsType>%s</VcsType>" % self.pdata["VCS"][0]) |
161 self._write(" <VcsType>{0}</VcsType>".format(self.pdata["VCS"][0])) |
161 if self.pdata["VCSOPTIONS"]: |
162 if self.pdata["VCSOPTIONS"]: |
162 self._write(" <VcsOptions>") |
163 self._write(" <VcsOptions>") |
163 self._writeBasics(self.pdata["VCSOPTIONS"][0], 3) |
164 self._writeBasics(self.pdata["VCSOPTIONS"][0], 3) |
164 self._write(" </VcsOptions>") |
165 self._write(" </VcsOptions>") |
165 if self.pdata["VCSOTHERDATA"]: |
166 if self.pdata["VCSOTHERDATA"]: |