587
|
1 |
#============================================================================
|
|
2 |
#Name : bomtofile.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 |
"""build of Materials to file writer"""
|
|
20 |
|
|
21 |
class BOMWriter(object):
|
628
|
22 |
""" Read BOM and output in text.
|
587
|
23 |
"""
|
|
24 |
def __init__(self, session, project_name, project, output_dir):
|
|
25 |
self.project_name = project_name
|
|
26 |
self.project = project
|
|
27 |
self.output_dir = output_dir
|
|
28 |
self.session = session
|
|
29 |
|
|
30 |
def writeprojects(self):
|
|
31 |
"""write projects"""
|
|
32 |
fileout = file(self.output_dir + '/' + self.project_name + '_projects.txt', 'w')
|
|
33 |
|
|
34 |
i = 1
|
|
35 |
for project in self.project.baseline:
|
|
36 |
fileout.write(str(i) + ") " + str(project) + "\n")
|
|
37 |
|
|
38 |
i += 1
|
|
39 |
fileout.close()
|
|
40 |
|
|
41 |
def writebaselines(self):
|
|
42 |
"""write baselines"""
|
|
43 |
fileout = file(self.output_dir + '/' + self.project_name + '_baselines.txt', 'w')
|
|
44 |
|
|
45 |
i = 1
|
|
46 |
for project in self.project.baseline:
|
|
47 |
fileout.write(str(i) + ") " + str(project) + "\n")
|
|
48 |
|
|
49 |
cmproject = self.session.create(str(project))
|
628
|
50 |
|
|
51 |
baseline = str(cmproject.baseline).strip()
|
|
52 |
if baseline == "None":
|
|
53 |
fileout.write(str(i) + ") " + str(project) + "\n")
|
|
54 |
else:
|
|
55 |
fileout.write(str(i) + ") " + baseline + "\n")
|
|
56 |
i += 1
|
587
|
57 |
|
|
58 |
fileout.close()
|
|
59 |
|
|
60 |
def writetasks(self):
|
|
61 |
"""write tasks"""
|
|
62 |
if self.project.xml_properties.has_key("task"):
|
|
63 |
fileout = file(self.output_dir + '/' + self.project_name + '_tasks.txt', 'w')
|
|
64 |
|
|
65 |
i = 1
|
|
66 |
for task in self.project.task:
|
|
67 |
fileout.write(str(i) + ") Task " + str(task) + "\n")
|
|
68 |
i += 1
|
|
69 |
fileout.close()
|