Go to the documentation of this file.00001
00002 """
00003 Small script to create the git tags for a release of Gaudi.
00004 """
00005 __author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"
00006
00007 import os
00008 import re
00009 from subprocess import Popen, PIPE, STDOUT
00010
00011 def requirements(path):
00012 """
00013 Generator yielding the paths of the requirements files in a tree.
00014 """
00015 for root, dirs, files in os.walk(path):
00016 if "requirements" in files:
00017 dirs[:] = []
00018 yield os.path.join(root, "requirements")
00019
00020 def getPackVer(requirements):
00021 """
00022 Extract package name and package version from a requirements file.
00023 """
00024 pattern = re.compile(r"^\s*(version|package)\s*(\S+)\s*$")
00025 data = dict([m.groups()
00026 for m in map(pattern.match, open(requirements))
00027 if m])
00028 return data.get("package", None), data.get("version", None)
00029
00030 def main():
00031
00032 root = os.path.realpath(__file__)
00033 root = os.path.dirname(root)
00034 root = os.path.dirname(root)
00035 root = os.path.dirname(root)
00036 for p, v in map(getPackVer, requirements(root)):
00037 if p and v:
00038 cmd = ["git", "tag", "%s/%s" % (p, v)]
00039 print " ".join(cmd) + ":",
00040 git = Popen(cmd, stdout=PIPE, stderr=PIPE)
00041 out, err = git .communicate()
00042 if git.returncode == 0:
00043 print "done"
00044 else:
00045 print "failed"
00046 elif p:
00047 print "WARNING: no version in package", p
00048 elif v:
00049 print "WARNING: found requirements with version (%s), but no package" % v
00050
00051 if __name__ == "__main__":
00052 main()