def walker(self, path=None, base_folder=None):
        """
        This method walk a directory structure and create the
        Folders and Files as they appear.
        """
        path = path or self.path or ''
        base_folder = base_folder or self.base_folder
        # prevent trailing slashes and other inconsistencies on path.
        path = os.path.normpath(upath(path))
        if base_folder:
            base_folder = os.path.normpath(upath(base_folder))
            print("The directory structure will be imported in %s" % (base_folder,))
        if self.verbosity >= 1:
            print("Import the folders and files in %s" % (path,))
        root_folder_name = os.path.basename(path)
        for root, dirs, files in os.walk(path):
            rel_folders = root.partition(path)[2].strip(os.path.sep).split(os.path.sep)
            while '' in rel_folders:
                rel_folders.remove('')
            if base_folder:
                folder_names = base_folder.split('/') + [root_folder_name] + rel_folders
            else:
                folder_names = [root_folder_name] + rel_folders
            folder = self.get_or_create_folder(folder_names)
            for file_obj in files:
                dj_file = DjangoFile(open(os.path.join(root, file_obj), mode='rb'),
                                     name=file_obj)
                self.import_file(file_obj=dj_file, folder=folder)
        if self.verbosity >= 1:
            print(('folder_created #%s / file_created #%s / ' + 'image_created #%s') % (self.folder_created, self.file_created, self.image_created))
def walker ( self , path = None , base_folder = None ) : path = path or self . path or '' base_folder = base_folder or self . base_folder path = os . path . normpath ( upath ( path ) ) if base_folder : base_folder = os . path . normpath ( upath ( base_folder ) ) print ( "The directory structure will be imported in %s" % ( base_folder , ) ) if self . verbosity >= 1 : print ( "Import the folders and files in %s" % ( path , ) ) root_folder_name = os . path . basename ( path ) for root , dirs , files in os . walk ( path ) : rel_folders = root . partition ( path ) [ 2 ] . strip ( os . path . sep ) . split ( os . path . sep ) while '' in rel_folders : rel_folders . remove ( '' ) if base_folder : folder_names = base_folder . split ( '/' ) + [ root_folder_name ] + rel_folders else : folder_names = [ root_folder_name ] + rel_folders folder = self . get_or_create_folder ( folder_names ) for file_obj in files : dj_file = DjangoFile ( open ( os . path . join ( root , file_obj ) , mode = 'rb' ) , name = file_obj ) self . import_file ( file_obj = dj_file , folder = folder ) if self . verbosity >= 1 : print ( ( 'folder_created #%s / file_created #%s / ' + 'image_created #%s' ) % ( self . folder_created , self . file_created , self . image_created ) )
This method walk a directory structure and create the
        Folders and Files as they appear.