| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
createProjVersHeader Namespace Reference

## Functions
def | main

## Variables
string | lhcb_ver_style "v(?P<maj_ver>[0-9]+)r(?P<min_ver>[0-9]+)(?:p(?P<pat_ver>[0-9]+))?"
string | atlas_ver_style "[A-Za-z]+\-(?P<maj_ver>[0-9]+)\-(?P<min_ver>[0-9]+)(?:\-(?P<pat_ver>[0-9]+))?"
string | plain_ver_style "(?P<maj_ver>[0-9]+)\.(?P<min_ver>[0-9]+)(?:\.(?P<pat_ver>[0-9]+))?"

## Function Documentation

def createProjVersHeader.main | ( |  | ) |

Definition at line 13 of file createProjVersHeader.py.

13
14 def main():
15 parser = OptionParser(usage="ERROR: Usage %prog <project> <version> <outputfile>")
16 parser.add_option("-q", "--quiet", action="store_true",
17 help="Do not print messages.")
18 opts, args = parser.parse_args()
19 if len(args) != 3:
20 parser.error("wrong number of arguments")
21
22 project, version, outputfile = args
23 if not opts.quiet:
24 print "Creating %s for %s %s" % (outputfile, project, version)
25
26 if version.startswith('HEAD'):
27 majver, minver, patver = 999, 999, 0 # special handling
28 else:
29 for style in [lhcb_ver_style, atlas_ver_style, plain_ver_style ] :
30 m = re.match(style, version)
31 if m :
32 break
33 majver = int(m.groupdict()['maj_ver'])
34 minver = int(m.groupdict()['min_ver'])
35 patver = int(m.groupdict()['pat_ver'] or 0)
36
37 outdir = os.path.dirname(outputfile)
38 if not os.path.exists(outdir):
39 if not opts.quiet:
40 print "Creating directory", outdir
41 os.makedirs(outdir)
42
43 # Prepare data to be written
44 outputdata = """#ifndef %(proj)s_VERSION
45 /* Automatically generated file: do not modify! */
46 #ifndef CALC_GAUDI_VERSION
47 #define CALC_GAUDI_VERSION(maj,min) (((maj) << 16) + (min))
48 #endif
49 #define %(proj)s_MAJOR_VERSION %(maj)d
50 #define %(proj)s_MINOR_VERSION %(min)d
51 #define %(proj)s_PATCH_VERSION %(pat)d
52 #define %(proj)s_VERSION CALC_GAUDI_VERSION(%(proj)s_MAJOR_VERSION,%(proj)s_MINOR_VERSION)
53 #endif
54 """ % { 'proj': project.upper(), 'min': minver, 'maj': majver, 'pat': patver }
55
56 # Get the current content of the destination file (if any)
57 try:
58 f = open(outputfile, "r")
59 olddata = f.read()
60 f.close()
61 except IOError:
62 olddata = None
63
64 # Overwrite the file only if there are changes
65 if outputdata != olddata:
66 open(outputfile, "w").write(outputdata)

## Variable Documentation

string createProjVersHeader.atlas_ver_style "[A-Za-z]+\-(?P<maj_ver>[0-9]+)\-(?P<min_ver>[0-9]+)(?:\-(?P<pat_ver>[0-9]+))?"

Definition at line 9 of file createProjVersHeader.py.

string createProjVersHeader.lhcb_ver_style "v(?P<maj_ver>[0-9]+)r(?P<min_ver>[0-9]+)(?:p(?P<pat_ver>[0-9]+))?"

Definition at line 8 of file createProjVersHeader.py.

string createProjVersHeader.plain_ver_style "(?P<maj_ver>[0-9]+)\.(?P<min_ver>[0-9]+)(?:\.(?P<pat_ver>[0-9]+))?"

Definition at line 10 of file createProjVersHeader.py.