|
1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 |
|
17 """ |
|
18 ExampleML implementation, for use as a template when creating new plug-ins. |
|
19 |
|
20 The example implementation language simply writes text data into output files |
|
21 using the specified encoding. The text data may contain ConfML setting references |
|
22 of the form ${SomeFeature.SomeSetting}. |
|
23 """ |
|
24 |
|
25 import os |
|
26 import sys |
|
27 import logging |
|
28 |
|
29 from cone.public import plugin |
|
30 |
|
31 class ExamplemlImpl(plugin.ImplBase): |
|
32 IMPL_TYPE_ID = 'exampleml' |
|
33 |
|
34 def __init__(self, resource_ref, configuration, output_objects): |
|
35 plugin.ImplBase.__init__(self, resource_ref, configuration) |
|
36 self.logger = logging.getLogger('cone.exampleml(%s)' % resource_ref) |
|
37 self.output_objects = output_objects |
|
38 |
|
39 def generate(self, context=None): |
|
40 for output in self.output_objects: |
|
41 self.logger.debug("Generating '%s'" % output.get_output_file(self.output, self.configuration)) |
|
42 output.write_to_file(self.output, self.configuration) |
|
43 |
|
44 def list_output_files(self): |
|
45 files = [] |
|
46 for output in self.output_objects: |
|
47 files.append(output.get_output_file(self.output, self.configuration)) |
|
48 return files |
|
49 |
|
50 def get_refs(self): |
|
51 refs = [] |
|
52 for output in self.output_objects: |
|
53 refs.extend(output.get_refs()) |
|
54 return refs |