587
|
1 |
#============================================================================
|
588
|
2 |
#Name : getvariantconfiguration.py
|
587
|
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 |
#===============================================================================
|
588
|
19 |
"""get variant configuration"""
|
587
|
20 |
|
|
21 |
import configuration
|
|
22 |
import sys
|
|
23 |
import os
|
|
24 |
import relnotes.variants
|
|
25 |
|
|
26 |
class VariantInfo(object):
|
|
27 |
""" This class holds the variant configuration details """
|
|
28 |
def __init__(self, variantdir):
|
|
29 |
self.__variantdir = variantdir
|
|
30 |
self.__cachestr = None
|
|
31 |
|
|
32 |
def __str__(self):
|
|
33 |
if self.__cachestr:
|
|
34 |
return self.__cachestr
|
|
35 |
self.__cachestr = ""
|
|
36 |
if not os.path.exists(self.__variantdir):
|
|
37 |
return self.__cachestr
|
|
38 |
for filename in os.listdir(self.__variantdir):
|
|
39 |
filename = os.path.join(self.__variantdir, filename)
|
|
40 |
if filename.endswith("_info.txt"):
|
|
41 |
print "Reading info from %s" % filename
|
|
42 |
data = relnotes.variants.parseInfo(filename)
|
|
43 |
if len(data) == 4:
|
|
44 |
output = "%s" % (data['name']) + ","
|
|
45 |
output += "%s" % (data['default']) + ","
|
|
46 |
output += "\"%s (%s)\"" % (",".join(data['languages']), ",".join(data['language.ids']))
|
|
47 |
self.__cachestr = output
|
|
48 |
return output
|
|
49 |
return self.__cachestr
|
|
50 |
|
|
51 |
def main():
|
|
52 |
""" Main function create a csv file that defines the variant configuration.
|
|
53 |
"""
|
|
54 |
product = sys.argv[1]
|
|
55 |
configfile = sys.argv[2]
|
|
56 |
outputfile = sys.argv[3]
|
|
57 |
|
|
58 |
try:
|
|
59 |
alreadyDone = {}
|
|
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():
|
|
65 |
if variant.type and variant.type.startswith("langpack_"):
|
|
66 |
if variant['PRODUCT_NAME'] not in alreadyDone:
|
|
67 |
alreadyDone[variant['PRODUCT_NAME']] = {}
|
|
68 |
if variant.type not in alreadyDone[variant['PRODUCT_NAME']] and variant['PRODUCT_NAME'] == product:
|
|
69 |
alreadyDone[variant['PRODUCT_NAME']][variant.type] = True
|
588
|
70 |
v_info = VariantInfo(variant['ROFS2_DIR'])
|
|
71 |
if len(str(v_info)) > 0:
|
|
72 |
outfile.write(str(v_info)+"\n")
|
587
|
73 |
outfile.close()
|
628
|
74 |
except IOError, exc:
|
587
|
75 |
print "ERROR: %s" % exc
|
|
76 |
sys.exit(-1)
|
|
77 |
|
|
78 |
sys.exit(0)
|
|
79 |
|
|
80 |
if __name__ == "__main__":
|
|
81 |
main()
|