def delete_collection(self, irods_collection): """Delete a collection in iRODS irods_collection : path (str)""" collInp = irods.collInp_t() irods.addKeyVal(collInp.condInput, irods.RECURSIVE_OPR__KW, "") collInp.collName = irods_collection return irods.rcRmColl(self.conn, collInp, 0)
def new_collection(self, irods_path): """Make a new directory in iRods""" collCreateInp = irods.collInp_t() irods.addKeyVal(collCreateInp.condInput, irods.RECURSIVE_OPR__KW, "") collCreateInp.collName = irods_path status = irods.rcCollCreate(self.conn, collCreateInp) return status
def __mkcolls( self, rods_path ): """ An os.makedirs() for iRODS collections. `rods_path` is the desired collection to create. """ assert rods_path.startswith( self.root_collection_path + '/' ), '__mkcolls(): Creating collections outside the root collection is not allowed (requested path was: %s)' % rods_path mkcolls = [] c = irods.irodsCollection( self.rods_conn, rods_path ) while c.getId() == -1: assert c.getCollName().startswith( self.root_collection_path + '/' ), '__mkcolls(): Attempted to move above the root collection: %s' % c.getCollName() mkcolls.append( c.getCollName() ) c.upCollection() for collname in reversed( mkcolls ): log.debug( 'Creating collection %s' % collname ) ci = irods.collInp_t() ci.collName = collname status = irods.rcCollCreate( self.rods_conn, ci ) assert status == 0, '__mkcolls(): Failed to create collection: %s' % collname