def detect_lines(diffstr):
 resultant_lines = {}
 io = StringIO(diffstr)
 encoding = 'utf-8'
 udiff = unidiff.PatchSet(io, encoding)
 for file in udiff:
  target_lines = []
  for hunk in file:
   target_lines += range(hunk.target_start, (hunk.target_start + hunk.target_length))
  resultant_lines[file.path] = target_lines
 return resultant_lines

def detect_lines ( diffstr ) : resultant_lines = { } io = StringIO ( diffstr ) encoding = 'utf-8' udiff = unidiff . PatchSet ( io , encoding ) for file in udiff : target_lines = [ ] for hunk in file : target_lines += range ( hunk . target_start , ( hunk . target_start + hunk . target_length ) ) resultant_lines [ file . path ] = target_lines return resultant_lines
take a diff string and return a dict of files with line numbers changed .