1 #============================================================================ |
|
2 #Name : getVariantConfiguration.py |
|
3 #Part of : Helium |
|
4 |
|
5 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
6 #All rights reserved. |
|
7 #This component and the accompanying materials are made available |
|
8 #under the terms of the License "Eclipse Public License v1.0" |
|
9 #which accompanies this distribution, and is available |
|
10 #at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
11 # |
|
12 #Initial Contributors: |
|
13 #Nokia Corporation - initial contribution. |
|
14 # |
|
15 #Contributors: |
|
16 # |
|
17 #Description: |
|
18 #=============================================================================== |
|
19 |
|
20 #--------------------------------------------------------------------------------------------------------------------------------------------- |
|
21 # Name: getVariantConfiguration.py |
|
22 # Synopsis: Extract the product variant configuration |
|
23 # |
|
24 # Requirements: |
|
25 # -Python 2.4 |
|
26 # |
|
27 # History: |
|
28 # Version: 1.0 23/5/2007 |
|
29 # First version |
|
30 #--------------------------------------------------------------------------------------------------------------------------------------------- |
|
31 |
|
32 |
|
33 import localisation |
|
34 import configuration |
|
35 import codecs |
|
36 import sys |
|
37 import escapeddict |
|
38 |
|
39 class VariantInfo(object): |
|
40 def __init__(self, variant, languagedb): |
|
41 self.__variant = variant |
|
42 self.__languagedb = languagedb |
|
43 |
|
44 def __str__(self): |
|
45 output = "%s (%s)" % (self.__variant['description'], self.__variant['variant.id']) + "," |
|
46 output += "%s (%s)" % (self.__languagedb.get_name(self.__variant['default']), self.__variant['default']) + "," |
|
47 output += "\"%s\"" % ",".join(map(lambda x: "%s (%s)" % (self.__languagedb.get_name(x), x), self.__variant['languages'])) |
|
48 return output |
|
49 |
|
50 def main(): |
|
51 """ Main function create a csv file that defines the variant configuration. |
|
52 """ |
|
53 product = sys.argv[1] |
|
54 languagefie = sys.argv[2] |
|
55 configfile = sys.argv[3] |
|
56 outputfile = sys.argv[4] |
|
57 |
|
58 try: |
|
59 languagedb = localisation.Languages(languagefie) |
|
60 builder = configuration.NestedConfigurationBuilder(open(configfile, 'r')) |
|
61 config_set = builder.getConfiguration() |
|
62 outfile = open(outputfile, "w+") |
|
63 outfile.write("Variant,Default language,Languages\n") |
|
64 for variant in config_set.getConfigurations(product): |
|
65 if variant.name == "languagepack": |
|
66 v = VariantInfo(variant, languagedb) |
|
67 outfile.write(str(v)+"\n") |
|
68 outfile.close() |
|
69 except Exception, exc: |
|
70 print "ERROR: %s" % exc |
|
71 sys.exit(-1) |
|
72 |
|
73 sys.exit(0) |
|
74 |
|
75 if __name__ == "__main__": |
|
76 main() |
|