Build number python script
[mussa.git] / makelib / buildnum.py
1 #!/usr/bin/python
2
3 import re
4 import subprocess
5 import sys
6
7 #_build_search = re.compile('^(Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)', re.MULTILINE)
8 _build_search = re.compile('</patch>', re.MULTILINE)
9
10 def getBuildNumber():
11   """Counts the number of patches that have been made and
12   returns that as the build number."""
13   
14   p = subprocess.Popen(['darcs', 'changes', '--xml-output'], stdout=subprocess.PIPE)
15   data = p.stdout.read()
16   build_num = len(_build_search.findall(data))
17   return build_num
18   
19 if __name__ == '__main__':
20   print "%s" % (getBuildNumber())