#!/usr/bin/python """ Contains the specrepository objects """ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2004 Dries Verachtert from log4py import Logger from storagefactory import StorageFactory class SpecRepositoryList: def __init__(self): self.__cat = Logger().get_instance(self) # configuration about each source (source of spec files) self.__specrepositories = [] # this array contains an array of SpecRepoFileList objects for each specrepo name #self.__specRepoFileListBySpecRepoName = {}; self.__myStorage = StorageFactory.getStorage() def add(self,specRepo): if specRepo != None: self.__specrepositories.append(specRepo) self.__storeSpecRepo(specRepo) def __storeSpecRepo(self, specRepo): id = self.__myStorage.saveSpecRepository(specRepo) specRepo.setId(id) def getSpecRepositoryByName(self,name): for sr in self.__specrepositories: if sr.getName() == name: return sr self.__cat.warn("no SpecRepository found with name: " + name) return None def getSpecRepositoryById(self,id): for sr in self.__specrepositories: if sr.getId() == id: return sr self.cat.warn("no SpecRepository found with id: " + str(id)) return None def getSpecRepoStats(self, sreponame): repo = self.getSpecRepositoryByName(sreponame) retval = repo.getName() + " (" + repo.getType() + "): " + str(len(self.specRepoFileListBySpecRepoName[sreponame])) + "\n" return retval def getConfig(self): retval = "" cnt = 0 for srepo in self.__specrepositories: retval = retval + "SpecRepository " + str(cnt) retval = retval + ": name=" + srepo.getName() + ", type=" retval = retval + srepo.getType() + ", rootdirectory=" + srepo.getRootDirectory() + "\n" rootdir = srepo.getRootDirectory() if posixpath.isdir(rootdir): retval = retval + "this rootdirectory exists\n" else: retval = retval + "this rootdir does not exist\n" cnt = cnt + 1 return retval def addMissingSpecRepositorySpecFileTagsPerDistro(self): for i in self.__specrepositories: self.__myStorage.addMissingSpecRepositorySpecFileTagsPerDistro(i) def updateAllFileLists(self): for i in self.__specrepositories: i.updateFileList() # a seperate program updates the spec file repositories. # result: the commands which have to be executed to update all the spec file repositories # example: "cd /a/b/c; svn update" def getSpecRepositoriesUpdateCommands(self): self.__cat.debug("start") retval = "" for repo in self.__specrepositories: retval = retval + repo.getUpdateCommand() + "\n" return retval