buildframework/helium/sf/python/pythoncore/lib/sysdef/io.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
child 645 b8d81fa19e7d
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
#Name        : io.py 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#===============================================================================
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    19
# pylint: disable=W0212,W0141
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
""" IO module for SystemDefinitionFile.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
    - Allow convertion to m,a 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
class FlashImageSizeWriter(object):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
    """ Writes a .csv file listing the content of the flash images. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
    def __init__(self, output):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
        """ Initialisation. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
        self.output = output
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
        self._out = file(output, 'w')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
    def write(self, sys_def, config_list):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
        """ Write the .csv data to a file for the given System Definition and configuration name. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
        self._out.write('component,binary,rom,rofs1,rofs2,rofs3\n')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
        for configuration in sys_def.configurations.values():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
            #print configuration.name  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
            if configuration.name in config_list:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
                for unit in configuration.units:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
                    #print str(unit.name) + '  ' + str(unit.binaries)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
                    for binary in unit.binaries:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
                        # Only print out the binaries for which there is size information
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
                        if hasattr(binary, 'size'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
                            rom_types = {'rom': 0, 'rofs1': 1, 'rofs2': 2, 'rofs3': 3}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
                            rom_type_values = ['', '', '', '']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
                            rom_type_values[rom_types[binary.rom_type]] = str(binary.size)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
                            rom_type_text = ','.join(rom_type_values)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
                            self._out.write('%s,%s,%s\n' % (unit.name, binary.name, rom_type_text))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
                    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
    def close(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        """ Closing the writer. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        self._out.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53