def seek_end_of_dict(module_data, start_line, start_col, next_node_line, next_node_col):
 if (next_node_line == None):
  snippet = module_data.splitlines()[start_line:]
  next_node_col = 0
  last_line_offset = 0
 else:
  snippet = module_data.splitlines()[start_line:next_node_line]
  last_line_offset = 1
 if (next_node_col == 0):
  for (line_idx, line) in tuple(reversed(tuple(enumerate(snippet))))[last_line_offset:]:
   end_col = None
   for (col_idx, char) in reversed(tuple(enumerate((c for c in line)))):
    if ((char == '}') and (end_col is None)):
     end_col = col_idx
    elif ((char == '#') and (end_col is not None)):
     end_col = None
   if (end_col is not None):
    end_line = (start_line + line_idx)
    break
 else:
  raise ParseError('Multiple statements per line confuses the module metadata parser.')
 return (end_line, end_col)

def seek_end_of_dict ( module_data , start_line , start_col , next_node_line , next_node_col ) : if ( next_node_line == None ) : snippet = module_data . splitlines ( ) [ start_line : ] next_node_col = 0 last_line_offset = 0 else : snippet = module_data . splitlines ( ) [ start_line : next_node_line ] last_line_offset = 1 if ( next_node_col == 0 ) : for ( line_idx , line ) in tuple ( reversed ( tuple ( enumerate ( snippet ) ) ) ) [ last_line_offset : ] : end_col = None for ( col_idx , char ) in reversed ( tuple ( enumerate ( ( c for c in line ) ) ) ) : if ( ( char == '}' ) and ( end_col is None ) ) : end_col = col_idx elif ( ( char == '#' ) and ( end_col is not None ) ) : end_col = None if ( end_col is not None ) : end_line = ( start_line + line_idx ) break else : raise ParseError ( 'Multiple statements per line confuses the module metadata parser.' ) return ( end_line , end_col )
look for the end of a dict in a set of lines we know the starting position of the dict and we know the start of the next code node but in between there may be multiple newlines and comments .