4 # from pprint import pprint
17 def startElement(self, tag, attrs):
31 def characters(self, data):
32 if self.inRevision == 1 or self.inAuthor == 1 or self.inLog == 1 or self.inFile == 1:
35 def endElement(self, tag):
38 self.revision = self.buffer
41 self.author = self.buffer
44 self.logmessage = self.buffer
47 self.filelist.append(self.buffer)
64 ctxt = libxml2.createPushParser(handler,"",0,"temp.xml")
65 myfile = file(self.filename)
66 for line in myfile.readlines():
67 ctxt.parseChunk(line,len(line),0)
68 ctxt.parseChunk("",0,1)
70 # Let's find out what dirs were touched
71 filelist = handler.filelist
83 while i < maxi and ok == 1:
84 search = filelist[i].find("/")
86 #okay, we have a fil in the "top" dir let's stop it
90 # we have a subdir in here, so count ;)
94 if ok == 1 and multidir == 0:
95 if subdirlinecount == maxi:
96 #okay all dirs still have a slash
97 # everything in the same dir?
103 if dir.find("/") > -1:
104 if dir[:dir.find("/")+1] != lastdir:
106 lastdir = dir[:dir.find("/")+1]
108 if subdirlinecount == 1:
109 # okay, all lines have the same slashpos.
110 # strip everything up to it
112 path += filelist[0][:search+1]
114 filelist[i] = filelist[i][search+1:]
117 for line in filelist:
121 #no we seem to have the topdir now..
122 dircount = subdirlinecount
132 if dir.find("/") > -1:
133 if dir[:dir.find("/")+1] != lastdir:
135 lastdir = dir[:dir.find("/")+1]
138 self.author = handler.author
139 self.revision = handler.revision
140 self.logmessage = handler.logmessage
141 self.dircount = dircount
142 self.filecount = filecount
143 self.filelist = filelist
145 def generate_pathline(self):
147 if (len(self.filelist) == 1):
148 self.pathline = self.path + self.filelist[0]
149 elif (self.filecount > 1 or self.filecount < 4) and self.dircount == 0:
150 self.pathline = self.path + " ("
151 for file in self.filelist:
152 self.pathline += file + " "
153 self.pathline = self.pathline[:-1] + ")"
154 elif self.filecount >= 1 and self.dircount >= 1 and self.filecount+self.dircount < 4:
155 self.pathline = self.path + " ("
156 for file in self.filelist:
157 self.pathline += file + " "
158 self.pathline = self.pathline[:-1] + ")"
159 elif self.filecount >= 1 and self.dircount >= 1 and self.filecount+self.dircount >= 4:
160 self.pathline = self.path + " ("
161 if self.filecount == 1:
162 self.pathline += "1 file"
163 if self.filecount > 1:
164 self.pathline += "%i files" % self.filecount
165 if self.dircount == 1:
166 self.pathline += " in 2 dirs"
167 if self.dircount > 1:
168 self.pathline += " in %i dirs" % (self.dircount)
173 self.generate_pathline()