#NEWLINE# def copyItem( self , srcItem , creator , name = None , folder = None , description = None ) : #NEWLINE# #INDENT# '\n        Copy an item, including duplicating files and metadata.\n\n        :param srcItem: the item to copy.\n        :type srcItem: dict\n        :param creator: the user who will own the copied item.\n        :param name: The name of the new item.  None to copy the original name.\n        :type name: str\n        :param folder: The parent folder of the new item.  None to store in the\n                same folder as the original item.\n        :param description: Description for the new item.  None to copy the\n                original description.\n        :type description: str\n        :returns: the new item.\n        ' #NEWLINE# if ( name is None ) : #NEWLINE# #INDENT# name = srcItem [ 'name' ] #NEWLINE# #UNINDENT# if ( folder is None ) : #NEWLINE# #INDENT# folder = self . model ( 'folder' ) . load ( srcItem [ 'folderId' ] , force = True ) #NEWLINE# #UNINDENT# if ( description is None ) : #NEWLINE# #INDENT# description = srcItem [ 'description' ] #NEWLINE# #UNINDENT# newItem = self . createItem ( folder = folder , name = name , creator = creator , description = description ) #NEWLINE# filteredItem = self . filter ( newItem , creator ) #NEWLINE# updated = False #NEWLINE# for key in srcItem : #NEWLINE# #INDENT# if ( ( key not in filteredItem ) and ( key not in name ) ) : #NEWLINE# #INDENT# newItem [ key ] = copy . deepcopy ( srcItem [ key ] ) #NEWLINE# updated = True #NEWLINE# #UNINDENT# #UNINDENT# if updated : #NEWLINE# #INDENT# self . save ( newItem , triggerEvents = False ) #NEWLINE# #UNINDENT# events . trigger ( 'model.item.copy.prepare' , ( srcItem , newItem ) ) #NEWLINE# for file in self . childFiles ( item = srcItem ) : #NEWLINE# #INDENT# self . model ( 'file' ) . copyFile ( file , creator = creator , item = newItem ) #NEWLINE# #UNINDENT# newItem = self . load ( newItem [ '_id' ] , force = True ) #NEWLINE# events . trigger ( 'model.item.copy.after' , newItem ) #NEWLINE# return newItem