configurationengine/source/plugins/symbian/ConeHCRPlugin/hcrplugin/header_writer.py
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
equal deleted inserted replaced
2:87cfa131b535 3:e7e0ae78773e
    15 #
    15 #
    16 
    16 
    17 import os
    17 import os
    18 
    18 
    19 class HeaderWriter(object):
    19 class HeaderWriter(object):
    20     def __init__(self,output_file, output_obj):
    20     def __init__(self, output_file, output_obj):
    21         self.output_obj = output_obj
    21         self.output_obj = output_obj
    22         self.output_file = output_file
    22         self.output_file = output_file
    23 
    23 
    24     def write(self):
    24     def write(self, context):
    25         header_guard = os.path.basename(self.output_file).upper()
    25         header_guard = os.path.basename(self.output_file).upper()
    26         header_guard = header_guard.replace('/', '_').replace('\\', '_').replace('.', '_')
    26         header_guard = header_guard.replace('/', '_').replace('\\', '_').replace('.', '_')
    27         lines = [
    27         lines = [
    28             "#ifndef %s" % header_guard,
    28             "#ifndef %s" % header_guard,
    29             "#define %s" % header_guard,
    29             "#define %s" % header_guard,
    54         lines.extend([
    54         lines.extend([
    55             "",
    55             "",
    56             "#endif",
    56             "#endif",
    57         ])
    57         ])
    58         
    58         
    59         f = open(self.output_file, 'wb')
    59         f = context.create_file(self.output_file, mode='wb')
    60         try:        f.write(os.linesep.join(lines))
    60         try:        f.write('\r\n'.join(lines))
    61         finally:    f.close()
    61         finally:    f.close()