#!/usr/bin/python ############################################################################# # Copyright (C) 2010 Spidcom # # Export for C file. ############################################################################# import os import string class C: """Generate a C table""" def __init__ (self): """Initialise the class. line description, enum description """ self.line = "#define %s %s\n" self.mmtypes = " %s = %s + %s,\n" self.mmtypes_min_max = "#define %s 0x%04x\n" self.define_is = "#define MMTYPE_IS_%s(mmtype) \\\n\ ((mmtype) >= %s && (mmtype) <= %s)\n" """Open template and get it.""" f = open (os.path.dirname (__file__) + '/ctemplate.txt', 'r') t = f.read () f.close () self.template = string.Template (t)