def checkUserName(value): profileManager = ProfileManager() if value not in profileManager.getProfileNames(): raise ValueError,"Profile [%s] not currently stored!\n" % (value)
if options.list and len(args) != 0: sys.stderr.write("List takes no arguments\n") sys.exit() if (options.save or options.restore or options.diff) and len(args) != 2: sys.stderr.write("Save, Restore and Diff take two arguments\n") sys.exit() setManager = SetManager() if (options.save or options.restore or options.examine or options.clear or options.diff): profileManager = ProfileManager() userName = args[0] if len(args) == 2: setName = args[1] if userName not in profileManager.getProfileNames(): sys.stderr.write("No such profile stored\n") sys.exit(0) if options.examine: session = profileManager.doLogin(userName) profile = UserProfile() if len(args) == 2: answer = profile.getAnswerFromSession(session,int(args[1])) sys.stderr.write("Answer [%s]\n" % answer) setManager.printSet({answer.Id : answer}) else: profile.loadFromSession(session,userName) setManager.printSet(profile.Answers) elif options.save: session = profileManager.doLogin(userName) profile = UserProfile()