generate_changelog.py

00001 #!/usr/bin/env python
00002 
00003 import subprocess
00004 import sys
00005 
00006 try:
00007     pipe = subprocess.Popen("bzr log", shell=True, stdout=subprocess.PIPE)
00008     logfile = pipe.communicate()[0]
00009 except ValueError:
00010     print("Error with my Pipe")
00011     sys.exit(-1)
00012 
00013 revisions = logfile.split("------------------------------------------------------------")
00014 revisions.reverse()
00015 revisions = revisions[:-1]
00016 
00017 
00018 class REVISION:
00019     def __init__(self, rev):
00020         self.revision=None
00021         self.comitter=None
00022         self.branch=None    
00023         self.timestamp=None
00024         self.message=None
00025 
00026         lines = rev.split("\n")[1:]
00027         self.revision = lines[0].strip().replace("revno: ", "")
00028         self.comitter = lines[1]
00029         self.branch = lines[2]
00030         self.timestamp = lines[3]
00031         self.message="\n".join(lines[4:]).strip()
00032 
00033     def __str__(self):
00034         ret = """revision: %s
00035 committer: %s
00036 branch: %s
00037 timestamp: %s
00038 message: %s
00039         """ % (self.revision, self.comitter, self.branch, self.timestamp, self.message)
00040         return ret
00041 
00042 revlist = []
00043 for rev in revisions:
00044     r = REVISION(rev)
00045     revlist.append(r)
00046 
00047 def get_revision(rev):
00048     return revisions[rev-1]
00049 
00050 def get_revisions(fromrev, torev):
00051     return revisions[fromrev-1: torev]
00052 
00053 
00054 #while 1:
00055 #    print(60*"*")
00056 #    print("Got %i revisions" % len(revlist))
00057 #    print("Lates revision: %s" % revlist[len(revlist)-1].revision)
00058 #    print("")
00059 #    print("What do you want to do?")
00060 #    print("""NUM = Show that revision
00061 #RANGE (1-10) = Print those revisions
00062 #EXIT = Exit
00063 #    """)
00064 #    ret = raw_input("Your Choice: ")
00065 #    print(60*"*")
00066 
00067 #    if "-" in ret:
00068 #        try:
00069 #            fr, to = ret.split("-")
00070 #            for r in revlist:
00071 #                if (r.revision) >= (fr) and (r.revision) <= (to):
00072 #                    print r
00073 #        except OSError:
00074 #            print("That was no valid range")
00075 #    elif ret.lower() == "exit":
00076 #        sys.exit()
00077 #    elif ret.isdigit():
00078 #        print 30*"="
00079 #        found = False
00080 #        for rev in revlist:
00081 #            if rev.revision == str(ret):
00082 #                found = True
00083 #                print rev
00084 #        if not found:
00085 #            print("The revision %s was not found" % ret)
00086 #        print 30*"="

Generated on Thu Jun 4 19:08:24 2009 for Pyjama by  doxygen 1.5.8