82 Overloading the default constructor |
83 Overloading the default constructor |
83 """ |
84 """ |
84 plugin.ImplBase.__init__(self,ref,configuration) |
85 plugin.ImplBase.__init__(self,ref,configuration) |
85 self.logger = logging.getLogger('cone.thememl') |
86 self.logger = logging.getLogger('cone.thememl') |
86 |
87 |
87 def build(self): |
88 def build(self, context): |
88 """ |
89 """ |
89 Building process of themes |
90 Building process of themes |
90 """ |
91 """ |
91 # Get absolute path so that copying works correctly |
92 # Get absolute path so that copying works correctly |
92 # despite working directory changing |
93 # despite working directory changing |
93 abs_output = os.path.abspath(os.path.join(self.output, "content")) |
94 abs_output = os.path.abspath(os.path.join(context.output, self.output, "content")) |
94 |
95 |
95 # get *.tpf files from the configuration |
96 # get *.tpf files from the configuration |
96 list_tpf = self.list_tpf_files(self.list_active_theme, self.list_theme_dir) |
97 list_tpf = self.list_tpf_files(self.list_active_theme, self.list_theme_dir) |
97 |
98 |
98 theme_container = ThemeContainer(list_tpf,self.configuration) |
99 theme_container = ThemeContainer(list_tpf,self.configuration) |
170 |
171 |
171 def generate(self, context=None): |
172 def generate(self, context=None): |
172 """ |
173 """ |
173 Generate the given implementation. |
174 Generate the given implementation. |
174 """ |
175 """ |
175 self.parse_impl() |
176 # Make sure autoconfig is the last layer, since theme conversion |
176 self.build() |
177 # may change the values of some settings |
|
178 autoconfig = plugin.get_autoconfig(self.configuration) |
|
179 |
|
180 self.build(context) |
|
181 |
|
182 # Add changed refs if necessary |
|
183 if context: |
|
184 context.add_changed_refs(autoconfig.list_leaf_datas()) |
177 |
185 |
178 return |
186 return |
179 |
187 |
180 def generate_layers(self,layers): |
188 def generate_layers(self,layers): |
181 """ |
189 """ |
189 """ |
197 """ |
190 @returns True if the implementation uses the given ref as input value. |
198 @returns True if the implementation uses the given ref as input value. |
191 Otherwise return False. |
199 Otherwise return False. |
192 """ |
200 """ |
193 return None |
201 return None |
194 |
|
195 def parse_impl(self): |
|
196 if self.configuration: |
|
197 resource =self.configuration.get_resource(self.ref) |
|
198 reader = ThemeImplReader() |
|
199 try: |
|
200 self.logger.info('Parses %s' % self.ref) |
|
201 reader.fromstring(resource.read()) |
|
202 self.carbide = reader.carbide |
|
203 except (SyntaxError),e: |
|
204 logging.getLogger('cone.thememl(%s)' % resource.get_path()).error('Invalid xml in layer root file. Exception: %s' % (e)) |
|
205 raise exceptions.ParseError('Invalid xml in layer root file (%s). Exception: %s' % (resource.get_path(),e)) |
|
206 self.list_theme_dir=reader.list_theme_dir |
|
207 self.list_active_theme=reader.list_active_theme |
|
208 self.theme_version = reader.theme_version |
|
209 resource.close() |
|
210 |
|
211 return |
|
212 |
202 |
213 def list_output_files(self): |
203 def list_output_files(self): |
214 """ |
204 """ |
215 Return a list of output files as an array. |
205 Return a list of output files as an array. |
216 """ |
206 """ |
221 class ThemeImplReader(plugin.ReaderBase): |
211 class ThemeImplReader(plugin.ReaderBase): |
222 """ |
212 """ |
223 Parses a single thememl file |
213 Parses a single thememl file |
224 """ |
214 """ |
225 NAMESPACE = 'http://www.s60.com/xml/thememl/1' |
215 NAMESPACE = 'http://www.s60.com/xml/thememl/1' |
|
216 NAMESPACE_ID = 'thememl' |
|
217 ROOT_ELEMENT_NAME = 'thememl' |
226 FILE_EXTENSIONS = ['thememl'] |
218 FILE_EXTENSIONS = ['thememl'] |
227 |
219 |
228 def __init__(self): |
220 def __init__(self): |
229 self.namespaces = [self.NAMESPACE] |
221 self.namespaces = [self.NAMESPACE] |
230 self.list_theme_dir = [] |
222 self.list_theme_dir = [] |
240 |
232 |
241 impl = ThemeImpl(resource_ref, configuration) |
233 impl = ThemeImpl(resource_ref, configuration) |
242 impl.list_theme_dir = reader.list_theme_dir |
234 impl.list_theme_dir = reader.list_theme_dir |
243 impl.list_active_theme = reader.list_active_theme |
235 impl.list_active_theme = reader.list_active_theme |
244 impl.theme_version = reader.theme_version |
236 impl.theme_version = reader.theme_version |
|
237 impl.carbide = reader.carbide |
245 return impl |
238 return impl |
|
239 |
|
240 @classmethod |
|
241 def get_schema_data(cls): |
|
242 return pkg_resources.resource_string('themeplugin', 'xsd/thememl.xsd') |
246 |
243 |
247 def fromstring(self, xml_as_string): |
244 def fromstring(self, xml_as_string): |
248 etree = ElementTree.fromstring(xml_as_string) |
245 etree = ElementTree.fromstring(xml_as_string) |
249 self.parse_thememl(etree) |
246 self.parse_thememl(etree) |
250 |
247 |