|
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 |
|
20 import amara |
|
21 import nokia.nokiaccm |
|
22 import ant |
|
23 |
|
24 class BOMWriter(object): |
|
25 """ |
|
26 Read BOM and output in text |
|
27 """ |
|
28 def __init__(self, session, project_name, project, output_dir): |
|
29 self.project_name = project_name |
|
30 self.project = project |
|
31 self.output_dir = output_dir |
|
32 self.session = session |
|
33 |
|
34 def writeprojects(self): |
|
35 fileout = file(self.output_dir + '/' + self.project_name + '_projects.txt', 'w') |
|
36 |
|
37 i = 1 |
|
38 for project in self.project.baseline: |
|
39 fileout.write(str(i) + ") " + str(project) + "\n") |
|
40 |
|
41 i += 1 |
|
42 fileout.close() |
|
43 |
|
44 def writebaselines(self): |
|
45 fileout = file(self.output_dir + '/' + self.project_name + '_baselines.txt', 'w') |
|
46 |
|
47 i = 1 |
|
48 for project in self.project.baseline: |
|
49 fileout.write(str(i) + ") " + str(project) + "\n") |
|
50 |
|
51 cmproject = self.session.create(str(project)) |
|
52 |
|
53 try: |
|
54 baseline = str(cmproject.baseline).strip() |
|
55 if baseline == "None": |
|
56 fileout.write(str(i) + ") " + str(project) + "\n") |
|
57 else: |
|
58 fileout.write(str(i) + ") " + baseline + "\n") |
|
59 i += 1 |
|
60 except Exception, ex: |
|
61 print ex |
|
62 fileout.close() |
|
63 |
|
64 def writetasks(self): |
|
65 if self.project.xml_properties.has_key("task"): |
|
66 fileout = file(self.output_dir + '/' + self.project_name + '_tasks.txt', 'w') |
|
67 |
|
68 i = 1 |
|
69 for task in self.project.task: |
|
70 fileout.write(str(i) + ") Task " + str(task) + "\n") |
|
71 i += 1 |
|
72 fileout.close() |
|
73 |
|
74 |
|
75 |