def parseCsv(filename, checkUrl): ''' create a list of events based on the input csv file ''' data = csv.reader(open(filename)) # Read the column names from the first line of the file fields = data.next() # class for the name of each event # print fields eventName = EventName(fields) eventList = [] # for each of the event given # create a event object for it with the data for row in data: # Zip together the field names and values items = zip(fields, row) componentUrl = {} # create a dictionary of component name to its url for this event for (name, value) in items: if not name.strip()== 'name': # Validate the url given if checkUrl and not validurl.verifyUrl(value.strip()): print >> sys.stderr, value.strip() + " invalid url" exit(1) componentUrl[name.strip()] = value.strip() e = event.Event(eventName(items), componentUrl) eventList.append(e) return eventList
def manualMode(opt): ''' Handle user input through command line to get url information for a event ''' print welcomeMessage eventName = raw_input("name of this event:") newEvent = event.Event(eventName) # collect information for each commponent for this event for com in componentList: if chooseComponent(com): url = readUrl(com) # validate the given url if requested by user if opt.verifyUrl: if not validurl.verifyUrl(url): print "ERROR: " + url + "is not valid. Abort." newEvent.addUrl(com, url) return [newEvent]