#NEWLINE# def importData( self , parent , parentType , params , progress , user ) : #NEWLINE# #INDENT# importPath = params [ 'importPath' ] #NEWLINE# if ( not os . path . isdir ( importPath ) ) : #NEWLINE# #INDENT# raise ValidationException ( ( 'No such directory: %s.' % importPath ) ) #NEWLINE# #UNINDENT# for name in os . listdir ( importPath ) : #NEWLINE# #INDENT# progress . update ( message = name ) #NEWLINE# path = os . path . join ( importPath , name ) #NEWLINE# if os . path . isdir ( path ) : #NEWLINE# #INDENT# folder = self . model ( 'folder' ) . createFolder ( parent = parent , name = name , parentType = parentType , creator = user , reuseExisting = True ) #NEWLINE# self . importData ( folder , 'folder' , params = { #NEWLINE# #INDENT# 'importPath' : os . path . join ( importPath , name ) , #NEWLINE# #UNINDENT# } , progress = progress , user = user ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( parentType != 'folder' ) : #NEWLINE# #INDENT# raise ValidationException ( ( 'Files cannot be imported directly underneath a %s.' % parentType ) ) #NEWLINE# #UNINDENT# item = self . model ( 'item' ) . createItem ( name = name , creator = user , folder = parent , reuseExisting = True ) #NEWLINE# self . importFile ( item , path , user , name = name )