labpack/storage/appdata.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__
        key_arg = '%s(record_key="%s")' % (title, record_key)

    # validate inputs
        record_key = self.fields.validate(record_key, '.record_key')

    # construct path to file
        file_path = os.path.join(self.collection_folder, record_key)

    # validate existence of file
        if not os.path.exists(file_path):
            exit_msg = '%s does not exist.' % record_key
            return exit_msg
    
    # delete file asynchronously
    #     if non_blocking:
    #         self._delete(file_path, title, record_key)
    #         exit_msg = '%s will be deleted.' % record_key
    #         return exit_msg
        
    # remove file
        current_dir = os.path.split(file_path)[0]
        try:
            os.remove(file_path)
        except:
            raise Exception('%s failed to delete %s' % (key_arg, record_key))

    # # remove empty directories in path to file
    #     if not os.listdir(current_dir):
    #         os.removedirs(current_dir)

    # remove empty directories in path to file
        while current_dir != self.collection_folder:
            if not os.listdir(current_dir):
                os.rmdir(current_dir)
                current_dir = os.path.split(current_dir)[0]
            else:
                break

        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__
        key_arg = '%s(record_key="%s")' % (title, record_key)
        record_key = self.fields.validate(record_key, '.record_key')
        file_path = os.path.join(self.collection_folder, record_key)
        if not os.path.exists(file_path):
            exit_msg = '%s does not exist.' % record_key
            return exit_msg
        current_dir = os.path.split(file_path)[0]
        try:
            os.remove(file_path)
        except:
            raise Exception('%s failed to delete %s' % (key_arg, record_key))
        while current_dir != self.collection_folder:
            if not os.listdir(current_dir):
                os.rmdir(current_dir)
                current_dir = os.path.split(current_dir)[0]
            else:
                break
        exit_msg = '%s has been deleted.' % record_key
        return exit_msg
def delete ( self , record_key ) : title = '%s.delete' % self . __class__ . __name__ key_arg = '%s(record_key="%s")' % ( title , record_key ) record_key = self . fields . validate ( record_key , '.record_key' ) file_path = os . path . join ( self . collection_folder , record_key ) if not os . path . exists ( file_path ) : exit_msg = '%s does not exist.' % record_key return exit_msg current_dir = os . path . split ( file_path ) [ 0 ] try : os . remove ( file_path ) except : raise Exception ( '%s failed to delete %s' % ( key_arg , record_key ) ) while current_dir != self . collection_folder : if not os . listdir ( current_dir ) : os . rmdir ( current_dir ) current_dir = os . path . split ( current_dir ) [ 0 ] else : break 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
 # construct path to file
 # validate existence of file
 # delete file asynchronously
 #     if non_blocking:
 #         self._delete(file_path, title, record_key)
 #         exit_msg = '%s will be deleted.' % record_key
 #         return exit_msg
 # remove file
 # # remove empty directories in path to file
 #     if not os.listdir(current_dir):
 #         os.removedirs(current_dir)
 # 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