def get_containing_library_from_library_dataset(trans, library_dataset):
 folder = library_dataset.folder
 while folder.parent:
  folder = folder.parent
 for library in trans.sa_session.query(trans.model.Library).filter(and_((trans.model.Library.table.c.deleted == false()), (trans.model.Library.table.c.name == folder.name))):
  if (library.root_folder == folder):
   return library
 return None

def get_containing_library_from_library_dataset ( trans , library_dataset ) : folder = library_dataset . folder while folder . parent : folder = folder . parent for library in trans . sa_session . query ( trans . model . Library ) . filter ( and_ ( ( trans . model . Library . table . c . deleted == false ( ) ) , ( trans . model . Library . table . c . name == folder . name ) ) ) : if ( library . root_folder == folder ) : return library return None
given a library_dataset .