Gaudi Framework, version v23r4

Home   Generated: Mon Sep 17 2012
Functions

createProjVersHeader Namespace Reference

Functions

def main

Function Documentation

def createProjVersHeader::main (  )

Definition at line 7 of file createProjVersHeader.py.

00008           :
00009     parser = OptionParser(usage="ERROR: Usage %prog <project> <version> <outputfile>")
00010     parser.add_option("-q", "--quiet", action="store_true",
00011                       help="Do not print messages.")
00012     opts, args = parser.parse_args()
00013     if len(args) != 3:
00014         parser.error("wrong number of arguments")
00015 
00016     project, version, outputfile = args
00017     if not opts.quiet:
00018         print "Creating %s for %s %s" % (outputfile, project, version)
00019 
00020     m = re.match("(v|([A-Za-z]+\-))(?P<maj_ver>[0-9]+)(r|\-)(?P<min_ver>[0-9]+)(?:(p|\-)(?P<pat_ver>[0-9]+))?", version)
00021     majver = int(m.groupdict()['maj_ver'])
00022     minver = int(m.groupdict()['min_ver'])
00023     patver = int(m.groupdict()['pat_ver'] or 0)
00024 
00025     outdir = os.path.dirname(outputfile)
00026     if not os.path.exists(outdir):
00027         if not opts.quiet:
00028             print "Creating directory", outdir
00029         os.makedirs(outdir)
00030 
00031     # Prepare data to be written
00032     outputdata = """#ifndef %(proj)s_VERSION
00033 /* Automatically generated file: do not modify! */
00034 #ifndef CALC_GAUDI_VERSION
00035 #define CALC_GAUDI_VERSION(maj,min) (((maj) << 16) + (min))
00036 #endif
00037 #define %(proj)s_MAJOR_VERSION %(maj)d
00038 #define %(proj)s_MINOR_VERSION %(min)d
00039 #define %(proj)s_PATCH_VERSION %(pat)d
00040 #define %(proj)s_VERSION CALC_GAUDI_VERSION(%(proj)s_MAJOR_VERSION,%(proj)s_MINOR_VERSION)
00041 #endif
00042 """ % { 'proj': project.upper(), 'min': minver, 'maj': majver, 'pat': patver }
00043 
00044     # Get the current content of the destination file (if any)
00045     try:
00046         f = open(outputfile, "r")
00047         olddata = f.read()
00048         f.close()
00049     except IOError:
00050         olddata = None
00051 
00052     # Overwrite the file only if there are changes
00053     if outputdata != olddata:
00054         open(outputfile, "w").write(outputdata)

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Sep 17 2012 13:49:53 for Gaudi Framework, version v23r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004