| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
git_tag_packages.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 Small script to create the git tags for a release of Gaudi.
4 """
5 __author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"
6
7 import os
8 import re
9 from subprocess import Popen, PIPE, STDOUT
10
11 def requirements(path):
12 """
13 Generator yielding the paths of the requirements files in a tree.
14 """
15 for root, dirs, files in os.walk(path):
16 if "requirements" in files:
17 dirs[:] = [] # no need to recurse if we have a 'requirements'
18 yield os.path.join(root, "requirements")
19
20 def getPackVer(requirements):
21 """
22 Extract package name and package version from a requirements file.
23 """
24 pattern = re.compile(r"^\s*(version|package)\s*(\S+)\s*$")
25 data = dict([m.groups()
26 for m in map(pattern.match, open(requirements))
27 if m])
28 return data.get("package", None), data.get("version", None)
29
30 def main():
31 #from optparse import OptionParser
32 root = os.path.realpath(__file__)
33 root = os.path.dirname(root)
34 root = os.path.dirname(root)
35 root = os.path.dirname(root)
36 for p, v in map(getPackVer, requirements(root)):
37 if p and v:
38 cmd = ["git", "tag", "%s/%s" % (p, v)]
39 print " ".join(cmd) + ":",
40 git = Popen(cmd, stdout=PIPE, stderr=PIPE)
41 out, err = git .communicate()
42 if git.returncode == 0:
43 print "done"
44 else:
45 print "failed"
46 elif p:
47 print "WARNING: no version in package", p
48 elif v:
49 print "WARNING: found requirements with version (%s), but no package" % v
50
51 if __name__ == "__main__":
52 main()