#NEWLINE# def _load_datastore( self , path = None , ds_name = None , ignore_errors = True ) : #NEWLINE# #INDENT# ds = DatastoreFactory . get_datastore ( datastore_name = ds_name , config = self . config , scope = self . sysname ) #NEWLINE# try : #NEWLINE# #INDENT# objects = [ ] #NEWLINE# for fn in os . listdir ( path ) : #NEWLINE# #INDENT# fp = os . path . join ( path , fn ) #NEWLINE# try : #NEWLINE# #INDENT# with open ( fp , 'r' ) as f : #NEWLINE# #INDENT# json_text = f . read ( ) #NEWLINE# #UNINDENT# obj = json . loads ( json_text ) #NEWLINE# if ( obj and ( type ( obj ) is list ) and ( obj [ 0 ] == 'COMPACTDUMP' ) ) : #NEWLINE# #INDENT# objects . extend ( obj [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# objects . append ( obj ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# if ignore_errors : #NEWLINE# #INDENT# log . warn ( ( 'load error id=%s err=%s' % ( fn , str ( ex ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ex #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if objects : #NEWLINE# #INDENT# for obj in objects : #NEWLINE# #INDENT# if ( '_rev' in obj ) : #NEWLINE# #INDENT# del obj [ '_rev' ] #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# res = ds . create_doc_mult ( ds_name ) #NEWLINE# log . info ( ( 'DatastoreLoader: Loaded %s objects into %s' % ( len ( res ) , ds_name ) ) ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# if ignore_errors : #NEWLINE# #INDENT# log . warn ( ( 'load error err=%s' % str ( ex ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ex #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# ds . close ( )