def expand_to_match(items):
 cfg2newlines = {}
 for (configuration, lines) in items:
  cfg2newlines[configuration] = []
 maxguard = (2 ** 30)
 while True:
  minimalsourceline = maxguard
  for (configuration, lines) in items:
   if lines:
    minimalsourceline = min(minimalsourceline, lines[0].sourceline)
  if (minimalsourceline == maxguard):
   break
  for (configuration, lines) in items:
   if (lines and (lines[0].sourceline <= minimalsourceline)):
    cfg2newlines[configuration].append(lines[0])
    del lines[0]
  number_of_lines = max((len(x) for x in cfg2newlines.values()))
  for newlines in cfg2newlines.values():
   add = (number_of_lines - len(newlines))
   newlines.extend((['\n'] * add))
 return cfg2newlines

def expand_to_match ( items ) : cfg2newlines = { } for ( configuration , lines ) in items : cfg2newlines [ configuration ] = [ ] maxguard = ( 2 ** 30 ) while True : minimalsourceline = maxguard for ( configuration , lines ) in items : if lines : minimalsourceline = min ( minimalsourceline , lines [ 0 ] . sourceline ) if ( minimalsourceline == maxguard ) : break for ( configuration , lines ) in items : if ( lines and ( lines [ 0 ] . sourceline <= minimalsourceline ) ) : cfg2newlines [ configuration ] . append ( lines [ 0 ] ) del lines [ 0 ] number_of_lines = max ( ( len ( x ) for x in cfg2newlines . values ( ) ) ) for newlines in cfg2newlines . values ( ) : add = ( number_of_lines - len ( newlines ) ) newlines . extend ( ( [ '\n' ] * add ) ) return cfg2newlines
insert empty lines so that all sources has matching line numbers for the same code .