Public Member Functions | |
def | __init__ |
def | parse_hdr |
def | parse_body |
def | split_ |
def | __str__ |
def | __repr__ |
def | check |
Public Attributes | |
children | |
meta | |
divs | |
Static Public Attributes | |
tuple | ptn = re.compile("^@@ (?P<ablk>[-\+,\d]*) (?P<bblk>[-\+,\d]*) @@$") |
tuple | hdr = property(lambda self:self[0]) |
tuple | nchild = property(_nchild) |
tuple | smry = property(_smry) |
tuple | rejoin = property(lambda self:"\n".join([str(c) for c in self.children])) |
Definition at line 211 of file svndiff.py.
def DybPython::svndiff::Block::__init__ | ( | self, | ||
args, | ||||
kwargs | ||||
) |
Reimplemented from DybPython::svndiff::Text.
Definition at line 214 of file svndiff.py.
00214 : 00215 Text.__init__(self, *args, **kwargs) 00216 self.children = [] 00217 self.parse_hdr() 00218 self.parse_body() 00219 self.check(verbose=False) 00220 def parse_hdr(self):
def DybPython::svndiff::Block::parse_hdr | ( | self | ) |
Definition at line 221 of file svndiff.py.
00221 : 00222 m = self.ptn.match(self[0]) 00223 assert m, ( "failed to match %s " % self[0] ) 00224 self.meta.update( m.groupdict() ) 00225 def parse_body(self, verbose=False):
def DybPython::svndiff::Block::parse_body | ( | self, | ||
verbose = False | ||||
) |
Definition at line 226 of file svndiff.py.
00226 : 00227 """ 00228 Looks for contiguous Hunks of text with the same first character. 00229 records prior when transitions to new contiguous first char, avoids fake initial hunk 00230 """ 00231 l,start = "<",0 00232 index = 0 00233 for i,line in enumerate(self + [">"]): 00234 if len(line)>0: 00235 c = line[0] 00236 else: 00237 c = "." 00238 assert c in " >@+-." 00239 if verbose: 00240 print "[%2d, %s,%s,%d] %s " % ( i+1,c,l,start+1, line) 00241 if c == l: 00242 pass 00243 else: 00244 if l == "<": 00245 pass 00246 else: 00247 hnk = Hunk( self[start:i], c=l, begin=start+1 , end=i , index=index ) 00248 self.children.append( hnk ) 00249 if hnk.smry != "": ## only hunks with non empty summaries qualify for an index 00250 index += 1 l = c
def DybPython::svndiff::Text::split_ | ( | self, | ||
cls, | ||||
predicate = lambda line:True , |
||||
offset = 0 | ||||
) | [inherited] |
Definition at line 140 of file svndiff.py.
00144 :True, offset=0 ): 00145 divs = [] 00146 for n,line in enumerate(self): 00147 if predicate(line): 00148 divs.append(n+offset) 00149 self.divs = divs 00150 children = [] 00151 for i, n in enumerate(divs): 00152 if i + 1 < len(divs): 00153 m = divs[i+1] 00154 else: 00155 m = len(self)
def DybPython::svndiff::Text::__str__ | ( | self | ) | [inherited] |
def DybPython::svndiff::Text::__repr__ | ( | self | ) | [inherited] |
Reimplemented in DybPython::svndiff::Delta.
Definition at line 166 of file svndiff.py.
00168 : 00169 return "\n".join(self) 00170 def __repr__(self): 00171 try: 00172 label = "%(index)s[%(begin)s:%(end)s]" % self.meta except KeyError:
def DybPython::svndiff::Text::check | ( | self, | ||
verbose = False , |
||||
hdr = None | ||||
) | [inherited] |
Check can put together the split text
Definition at line 175 of file svndiff.py.
00177 :"\n".join([str(c) for c in self.children])) 00178 00179 def check(self, verbose=False, hdr=None ): 00180 """Check can put together the split text """ 00181 rejo = self.rejoin 00182 if hdr: 00183 rejo = "\n".join([ hdr, rejo]) 00184 00185 agree = str(self) == rejo 00186 00187 if verbose or not(agree): 00188 print "." * 50 + " original " + "." * 50 00189 print str(self) 00190 print "." * 50 + " recombined " + "." * 50 00191 print rejo
tuple DybPython::svndiff::Block::ptn = re.compile("^@@ (?P<ablk>[-\+,\d]*) (?P<bblk>[-\+,\d]*) @@$") [static] |
Definition at line 212 of file svndiff.py.
tuple DybPython::svndiff::Block::hdr = property(lambda self:self[0]) [static] |
Definition at line 213 of file svndiff.py.
tuple DybPython::svndiff::Text::nchild = property(_nchild) [static, inherited] |
Definition at line 158 of file svndiff.py.
tuple DybPython::svndiff::Text::smry = property(_smry) [static, inherited] |
tuple DybPython::svndiff::Text::rejoin = property(lambda self:"\n".join([str(c) for c in self.children])) [static, inherited] |
Definition at line 173 of file svndiff.py.
DybPython::svndiff::Text::meta [inherited] |
Definition at line 135 of file svndiff.py.
DybPython::svndiff::Text::divs [inherited] |
Definition at line 137 of file svndiff.py.