def tradePlayersUI(): if printLeagues(): return 1 le = raw_input('Enter the name of the league the teams are in: ').strip() if printTeams(le): return 1 t1 = raw_input('Enter the name of the team to trade from: ').strip() t2 = raw_input('Enter the name of the team to trade to: ').strip() if printPlayers(le,t1): print 'Cannot trade from empty roster %s.' % t1 return 1 pls1=[] pls2=[] plo1=[] plo2=[] if not printPlayers(le,t2): promptInp = ' ' while promptInp.lower() not in ['n','no']: pls1.append(raw_input('Enter player from %s to trade: '%t1).strip()) promptInp = raw_input('Would you like to trade another player? (y/n): ' ).strip() while promptInp.lower() not in ['y','yes','n','no']: promptInp = raw_input('Invalid input. Please try again: ').strip() promptInp = ' ' while promptInp.lower() not in ['n','no']: pls2.append(raw_input('Enter player from %s to trade: '%t2).strip()) promptInp = raw_input('Would you like to trade another player? (y/n): ' ).strip() while promptInp.lower() not in ['y','yes','n','no']: promptInp = raw_input('Invalid input. Please try again: ').strip() pls1=list(set(pls1)) #cast as set, then as list to rid of pls2=list(set(pls2)) #potential dups else: promptInp = ' ' while promptInp.lower() not in ['n','no']: pls1.append(raw_input('Enter player from %s to trade: '%t1).strip()) promptInp = raw_input('Would you like to trade another player? (y/n): ' ).strip() while promptInp.lower() not in ['y','yes','n','no']: promptInp = raw_input('Invalid input. Please try again: ').strip() for i in pls1: j=nflgame.find(i,team=None) if j: plo1.append(j[0]) for i in pls2: j=nflgame.find(i,team=None) if j: plo2.append(j[0]) testVar = fbTool.tradePlayers(plo1,plo2,le,t1,t2) if not testVar: print 'successfully traded' print pls1 print 'from %s to %s for'%(t1,t2) print pls2 if testVar == 1: print 'League does not exist.' if testVar == 2: print 'Roster does not exist.' if testVar == 3: print 'Player not on roster.'
def but(): if not leagues.currentItem(): QMessageBox.critical(window,'error','League not selected from league list') elif not rosters1.currentItem(): QMessageBox.critical(window,'error','Roster not selected from top rosters box') elif not rosters2.currentItem(): QMessageBox.critical(window,'error','Roster not selected from bottom rosters box') elif not roster1.currentItem(): QMessageBox.critical(window,'error','Player not selected from top roster') elif not roster2.currentItem(): QMessageBox.critical(window,'error','Player not selected from the bottom roster') elif roster1.currentItem().text()==roster2.currentItem().text(): QMessageBox.critical(window,'error','Roster cannot trade to self') else: ln = str(leagues.currentItem().text()) r1 = str(rosters1.currentItem().text()) r2 = str(rosters2.currentItem().text()) ret = fbTool.tradePlayers(pl1,pl2,ln,r1,r2) if ret: QMessageBox.critical(window,'error','Something is broken.') else: popRoster1() popRoster2() mainMenu.updateTree()