import os class GetProjects: available_projects = [] current_projects = [] new_projects = [] repo_path = "/home/svn/" trac_path = "/usr/local/trac/env" def get_project_list(self): """gets the available projects and the current projects, and offers any new ones for addition to the trac setup""" print "Getting list of available projects..." available_projects = os.listdir(self.repo_path) current_projects = os.listdir(self.trac_path) print "AVAILABLE: ", available_projects #get the difference between project lists #new_projects = list(set(available_projects) - set(current_projects)) don't work with python 2.1 for project in available_projects: if project not in current_projects: self.new_projects.append(project) for object in self.new_projects: if os.path.isfile(self.repo_path+object): print "ISFILE: ", self.repo_path+object self.new_projects.remove(object) return self.new_projects if __name__=="__main__": getProjects = GetProjects() list_new_prjcts = getProjects.get_project_list() print "back in __init__ -", list_new_prjcts