def __init__(self, projectFile, keywordsFile, databaseFile): cmd.Cmd.__init__(self) # define command-line prompt self.prompt = 'sfr > ' # define list data self.projectList = [] self.keywordsList = [] self.databaseList = [] self.projectFile = projectFile self.keywordsFile = keywordsFile self.databaseFile = databaseFile # define search period self.startDate = date(1995,1,1) self.endDate = date.fromtimestamp(time.time()) print "setting search range from %s to %s" % (self.startDate.isoformat(), self.endDate.isoformat()) print " " # read projectFile with open(projectFile, 'rb') as csvfile: projectReader = csv.reader(csvfile, delimiter=',') for row in projectReader: projectEntry = SfProject(row[0], 0) projectEntry.setRemoteUrl(row[1]) projectEntry.setLocalUrl(row[2]) projectEntry.setRcs(row[3]) self.projectList.append(projectEntry) print "added project %s" % (projectEntry.getProjectName()) # print status message print "loaded %i projects" % (len(self.projectList)) print " " # read keywords self.keywordsList = open(keywordsFile).readlines() # print status message for keyword in self.keywordsList: print "added keyword %s " % (keyword) print "loaded %i keywords" % (len(self.keywordsList)) print " " # read database file self.readDatabase() # print status message print "loaded %i database entries" % (len(self.databaseList))
def do_addproject(self, line): "add the project to the list of projects" if line: elements = line.split() projectName, projectRemoteUrl, projectLocalUrl, projectRcs = "", "", "", "" projectName = elements[0] if len(elements) > 1: projectRemoteUrl = elements[1] if len(elements) > 2: projectLocalUrl = elements[2] if len(elements) > 3: projectRcs = elements[3] projectEntry = SfProject(projectName, 0) projectEntry.setRemoteUrl(projectRemoteUrl) projectEntry.setLocalUrl(projectLocalUrl) projectEntry.setRcs(projectRcs) self.projectList.append(projectEntry) print "added project %s (%s, %s, %s) to the list" % (projectName, projectRemoteUrl, projectLocalUrl, projectRcs) return
sys.exit(retVal) # set command line parameters projectFile, databaseFile, relationsFile, quiet, verbose = retVal # define list data projectList = [] databaseList = [] relationsList = [] hashList = {} # read projectFile with open(projectFile, 'rb') as csvfile: projectReader = csv.reader(csvfile, delimiter=',') for row in projectReader: projectEntry = SfProject(row[0], 0) projectEntry.setRemoteUrl(row[1]) projectEntry.setLocalUrl(row[2]) projectEntry.setRcs(row[3]) projectList.append(projectEntry) print "added project %s" % (projectEntry.getProjectName()) # print status message print "loaded %i projects" % (len(projectList)) print " " # read database file databaseList = readDatabase(databaseFile) # print status message print "loaded %i database entries" % (len(databaseList))
for projectEntry in projectData: # extract project information from the project data list projectName, projectId, projectVersion, projectUrl, projectTimePeriod, projectDependencies = projectEntry # check the project list for a project with a similar id # assume that we did not find it, yet found = False for sfproject in projectList: if projectId == sfproject.getProjectId(): found = True break if not found: # create a new project list entry sfproject = SfProject(projectName, projectId) # set up dependency object dependency = Dependency() dependency.setTimePeriodStart(projectTimePeriod[0]) dependency.setTimePeriodEnd(projectTimePeriod[1]) dependency.setVersion(projectVersion) dependency.setUrl(projectUrl) for dep in projectDependencies: dependency.addDependency(dep) sfproject.addProjectDependencyEntry(dependency) if not found: projectList.append(sfproject) testEnde1 = time.clock()