labpack/storage/dropbox.py
def delete(self, record_key):

        ''' a method to delete a file

        :param record_key: string with name of file
        :return: string reporting outcome
        '''

        title = '%s.delete' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'record_key': record_key
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)

    # validate existence of file
        if not self.exists(record_key):
            exit_msg = '%s does not exist.' % record_key
            return exit_msg
            
    # remove file
        current_dir = os.path.split(record_key)[0]
        try:
            file_path = '/%s' % record_key
            self.dropbox.files_delete(file_path)
        except:
            raise DropboxConnectionError(title)

    # remove empty directories in path to file
        try:
            while current_dir:
                folder_path = '/%s' % current_dir
                response = self.dropbox.files_list_folder(folder_path)
                if not response.entries:
                    self.dropbox.files_delete(folder_path)
                    current_dir = os.path.split(current_dir)[0]
                else:
                    break
        except:
            raise DropboxConnectionError(title)

        exit_msg = '%s has been deleted.' % record_key
        return exit_msg
 a method to delete a file

        :param record_key: string with name of file
        :return: string reporting outcome
        
a method to delete a file
a method to delete a file
def delete(self, record_key):
        title = '%s.delete' % self.__class__.__name__
        input_fields = {
            'record_key': record_key
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)
        if not self.exists(record_key):
            exit_msg = '%s does not exist.' % record_key
            return exit_msg
        current_dir = os.path.split(record_key)[0]
        try:
            file_path = '/%s' % record_key
            self.dropbox.files_delete(file_path)
        except:
            raise DropboxConnectionError(title)
        try:
            while current_dir:
                folder_path = '/%s' % current_dir
                response = self.dropbox.files_list_folder(folder_path)
                if not response.entries:
                    self.dropbox.files_delete(folder_path)
                    current_dir = os.path.split(current_dir)[0]
                else:
                    break
        except:
            raise DropboxConnectionError(title)
        exit_msg = '%s has been deleted.' % record_key
        return exit_msg
def delete ( self , record_key ) : title = '%s.delete' % self . __class__ . __name__ input_fields = { 'record_key' : record_key } for key , value in input_fields . items ( ) : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) if not self . exists ( record_key ) : exit_msg = '%s does not exist.' % record_key return exit_msg current_dir = os . path . split ( record_key ) [ 0 ] try : file_path = '/%s' % record_key self . dropbox . files_delete ( file_path ) except : raise DropboxConnectionError ( title ) try : while current_dir : folder_path = '/%s' % current_dir response = self . dropbox . files_list_folder ( folder_path ) if not response . entries : self . dropbox . files_delete ( folder_path ) current_dir = os . path . split ( current_dir ) [ 0 ] else : break except : raise DropboxConnectionError ( title ) exit_msg = '%s has been deleted.' % record_key return exit_msg
a method to delete a file
a method to delete a file
''' a method to delete a file

        :param record_key: string with name of file
        :return: string reporting outcome
        ''' # validate inputs
 # validate existence of file
 # remove file
 # remove empty directories in path to file

string reporting outcome
string reporting outcome
self
record_key
string with name of file
string with name of file