def SplitPatch(data):
 patches = []
 filename = None
 diff = []
 for line in data.splitlines(True):
  new_filename = None
  if line.startswith('Index:'):
   (unused, new_filename) = line.split(':', 1)
   new_filename = new_filename.strip()
  elif line.startswith('Property changes on:'):
   (unused, temp_filename) = line.split(':', 1)
   temp_filename = to_slash(temp_filename.strip())
   if (temp_filename != filename):
    new_filename = temp_filename
  if new_filename:
   if (filename and diff):
    patches.append((filename, ''.join(diff)))
   filename = new_filename
   diff = [line]
   continue
  if (diff is not None):
   diff.append(line)
 if (filename and diff):
  patches.append((filename, ''.join(diff)))
 return patches

def SplitPatch ( data ) : patches = [ ] filename = None diff = [ ] for line in data . splitlines ( True ) : new_filename = None if line . startswith ( 'Index:' ) : ( unused , new_filename ) = line . split ( ':' , 1 ) new_filename = new_filename . strip ( ) elif line . startswith ( 'Property changes on:' ) : ( unused , temp_filename ) = line . split ( ':' , 1 ) temp_filename = to_slash ( temp_filename . strip ( ) ) if ( temp_filename != filename ) : new_filename = temp_filename if new_filename : if ( filename and diff ) : patches . append ( ( filename , '' . join ( diff ) ) ) filename = new_filename diff = [ line ] continue if ( diff is not None ) : diff . append ( line ) if ( filename and diff ) : patches . append ( ( filename , '' . join ( diff ) ) ) return patches
splits a patch into separate pieces for each file .