587
|
1 |
#============================================================================
|
|
2 |
#Name : io.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 |
#===============================================================================
|
628
|
19 |
# pylint: disable=W0212,W0141
|
587
|
20 |
""" IO module for SystemDefinitionFile.
|
|
21 |
- Allow convertion to m,a
|
|
22 |
"""
|
|
23 |
|
|
24 |
class FlashImageSizeWriter(object):
|
|
25 |
""" Writes a .csv file listing the content of the flash images. """
|
|
26 |
def __init__(self, output):
|
|
27 |
""" Initialisation. """
|
|
28 |
self.output = output
|
|
29 |
self._out = file(output, 'w')
|
|
30 |
|
|
31 |
def write(self, sys_def, config_list):
|
|
32 |
""" Write the .csv data to a file for the given System Definition and configuration name. """
|
|
33 |
self._out.write('component,binary,rom,rofs1,rofs2,rofs3\n')
|
|
34 |
for configuration in sys_def.configurations.values():
|
|
35 |
#print configuration.name
|
|
36 |
if configuration.name in config_list:
|
|
37 |
for unit in configuration.units:
|
|
38 |
#print str(unit.name) + ' ' + str(unit.binaries)
|
|
39 |
for binary in unit.binaries:
|
|
40 |
# Only print out the binaries for which there is size information
|
|
41 |
if hasattr(binary, 'size'):
|
|
42 |
rom_types = {'rom': 0, 'rofs1': 1, 'rofs2': 2, 'rofs3': 3}
|
|
43 |
rom_type_values = ['', '', '', '']
|
|
44 |
rom_type_values[rom_types[binary.rom_type]] = str(binary.size)
|
|
45 |
rom_type_text = ','.join(rom_type_values)
|
|
46 |
self._out.write('%s,%s,%s\n' % (unit.name, binary.name, rom_type_text))
|
|
47 |
|
|
48 |
def close(self):
|
|
49 |
""" Closing the writer. """
|
|
50 |
self._out.close()
|
|
51 |
|
|
52 |
|
|
53 |
|