587
|
1 |
#============================================================================
|
|
2 |
#Name : icf2txt.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 |
#===============================================================================
|
588
|
19 |
""" icf 2 text"""
|
587
|
20 |
|
|
21 |
import sys
|
|
22 |
import amara
|
|
23 |
import os
|
|
24 |
|
|
25 |
def get_icfs(filename):
|
|
26 |
""" Read the list of icfs from the BOM. """
|
|
27 |
result = []
|
|
28 |
bomxmlFile = open(filename, "r")
|
|
29 |
bomxml = amara.parse(bomxmlFile)
|
|
30 |
if hasattr(bomxml.bom.content.project, "icf"):
|
|
31 |
for icf in bomxml.bom.content.project.icf:
|
|
32 |
result.append(str(icf))
|
|
33 |
bomxmlFile.close()
|
|
34 |
return result
|
|
35 |
|
|
36 |
def main():
|
588
|
37 |
"""main method in the file"""
|
587
|
38 |
if len(sys.argv) != 3:
|
|
39 |
print "Usage: icf2txt.py bom.xml out.txt"
|
|
40 |
sys.exit(1)
|
|
41 |
|
|
42 |
result = ['BOM not generated, the list of ICFs could not be generated']
|
|
43 |
if os.path.exists(sys.argv[1]):
|
|
44 |
result = get_icfs(sys.argv[1])
|
|
45 |
|
|
46 |
outFile = open(sys.argv[2], "w")
|
|
47 |
for icf in result:
|
|
48 |
outFile.write(str(icf) + "\n")
|
|
49 |
outFile.close()
|
|
50 |
|
|
51 |
|
|
52 |
if __name__ == "__main__":
|
|
53 |
main() |