#NEWLINE# def get_generator( data ) : #NEWLINE# #INDENT# '\n    In case of a big dataset, no need to load the entire list in memory, it can be given to\n    cartesius as a generator function.\n\n    In case data is callable and the result is a generator, then data is returned, oherwisea the\n    result is a function that returns a generator through data.\n    ' #NEWLINE# if callable ( data ) : #NEWLINE# #INDENT# if isinstance ( data ( ) , mod_types . GeneratorType ) : #NEWLINE# #INDENT# return data #NEWLINE# #UNINDENT# #UNINDENT# if ( not data ) : #NEWLINE# #INDENT# raise Exception ( 'Invalid or empty data: {0}' . format ( data ) ) #NEWLINE# #UNINDENT# def generator( ) : #NEWLINE# #INDENT# for i in data : #NEWLINE# #INDENT# ( yield i ) #NEWLINE# #UNINDENT# #UNINDENT# return data