How to use selectedItems method in fMBT

Best Python code snippet using fMBT_python

main.py

Source:main.py Github

copy

Full Screen

1import datetime2from flask import Flask, render_template, request3from models import CoDStats, Team, Player4import pandas as pd5import requests6app = Flask(__name__)7stats = CoDStats()8@app.route("/")9def index():10 # get last updated time and message11 data = requests.get('https://api.github.com/repos/cford23/cod-stats-tool/commits/master').json()12 date = data['commit']['author']['date'].partition('T')[0]13 year = int(date.partition('-')[0])14 month = int(date.partition('-')[2].partition('-')[0])15 day = int(date.partition('-')[2].partition('-')[2])16 time = data['commit']['author']['date'].partition('T')[2]17 time = time[:-1]18 hour = int(time.partition(':')[0])19 minutes = int(time.partition(':')[2].partition(':')[0])20 seconds = int(time.partition(':')[2].partition(':')[2])21 updated = datetime.datetime.combine(datetime.date(year, month, day), datetime.time(hour, minutes, seconds))22 msg = data['commit']['message']23 updated = updated.replace(tzinfo=datetime.timezone.utc).astimezone(tz=None)24 return render_template("index.html", hour=updated.strftime("%I"), minutes=updated.strftime("%M"), seconds=updated.strftime("%S"),25 ampm=updated.strftime("%p"), month=updated.strftime("%B"), day=day, year=year, msg=msg)26@app.route("/viewMatches", methods=["GET", "POST"])27def viewMatches():28 selectedItems = ['', '', '']29 wins = 030 losses = 031 if request.method == "POST" or request.method == "GET":32 team = request.form.get("team")33 selectedItems[0] = team34 opponent = request.form.get("opponent")35 selectedItems[1] = opponent36 event = request.form.get("event")37 selectedItems[2] = event38 results = stats.getMatches(team, opponent, event)39 length = results.shape[0]40 if team != 'All':41 wins, losses = stats.getViewMatchRecord(team, results)42 #return render_template("viewMatches.html", stats=stats, tables=[results.to_html(classes="data", index=False)], selectedItems=selectedItems, length=length, team=team, wins=wins, losses=losses)43 return render_template("viewMatches.html", stats=stats, data=results.to_dict(orient='records'),44 selectedItems=selectedItems, length=length, team=team, wins=wins, losses=losses)45@app.route("/matchView/<matchID>")46def matchView(matchID):47 matchID = int(matchID)48 data = stats.getMatchData(matchID=matchID).iloc[0]49 mapData = stats.getMapData(matchID=matchID)50 playerData = stats.getPlayerData(matchID=matchID)51 team1 = data['Team 1']52 team2 = data['Team 2']53 team1Abbr = stats.teamAbbrs[data['Team 1']]54 team2Abbr = stats.teamAbbrs[data['Team 2']]55 overall = playerData.groupby(['Player', 'Team'])[['Score', 'Kills', 'Deaths', 'Damage']].sum()56 overall['K/D'] = round(overall['Kills'] / overall['Deaths'], 2)57 overall['Engagements'] = overall['Kills'] + overall['Deaths']58 overall['Difference'] = overall['Kills'] - overall['Deaths']59 overall = overall.reset_index()60 overall = pd.DataFrame(overall, columns=['Team', 'Player', 'Score', 'Kills', 'Deaths', 'K/D', 'Engagements', 'Difference', 'Damage'])61 overall = overall.sort_values(by='Team')62 return render_template("matchView.html", data=data.to_dict(), mapData=mapData.to_dict(orient='records'),63 playerData=playerData.to_dict(orient='records'), team1=team1, team2=team2,64 team1Abbr=team1Abbr, team2Abbr=team2Abbr, overall=overall.to_dict(orient='records'))65@app.route("/viewMaps", methods=["GET", "POST"])66def viewMaps():67 selectedItems = ['', '', '', '', '']68 wins = 069 losses = 070 if request.method == "POST" or request.method == "GET":71 team = request.form.get("team")72 opponent = request.form.get("opponent")73 event = request.form.get("event")74 mode = request.form.get("mode")75 map = request.form.get("map")76 selectedItems[0] = team77 selectedItems[1] = opponent78 selectedItems[2] = event79 selectedItems[3] = mode80 selectedItems[4] = map81 results = stats.getMaps(team, opponent, event, mode, map)82 # delete Match ID and Map ID columns83 del results['Match ID']84 del results['Map ID']85 length = results.shape[0]86 if team != 'All':87 wins, losses = stats.getViewMapRecord(team, results)88 return render_template("viewMaps.html", stats=stats, data=results.to_dict(orient='records'),89 selectedItems=selectedItems, length=length, wins=wins, losses=losses, team=team)90 # return render_template("viewMaps.html", stats=stats, tables=[results.to_html(classes="data", index=False)], selectedItems=selectedItems, length=length, wins=wins, losses=losses, team=team)91@app.route("/viewPlayers", methods=["GET", "POST"])92def viewPlayers():93 player = Player()94 selectedItems = ['', '', '', '', '', '']95 playerTeams = []96 playerEvents = []97 kills = 098 deaths = 099 kd = 0100 mapRecord = [0, 0]101 results = stats.players.head(0)102 results = results.set_index(['Match ID', 'Map ID'])103 length = results.shape[0]104 if request.method == "POST":105 player = Player(request.form.get("player"))106 team = request.form.get("team")107 opponent = request.form.get("opponent")108 event = request.form.get("event")109 mode = request.form.get("mode")110 map = request.form.get("map")111 selectedItems[0] = player.name112 selectedItems[1] = team113 selectedItems[2] = opponent114 selectedItems[3] = event115 selectedItems[4] = mode116 selectedItems[5] = map117 playerTeams = player.getPlayerTeams()118 playerEvents = player.getPlayerEvents()119 results = stats.getPlayers(player.name, team, opponent, event, mode, map)120 # don't show Match ID and Map ID columns121 results = results.set_index(['Match ID', 'Map ID'])122 results.dropna(how='all', axis=1, inplace=True)123 kills, deaths, kd = player.getPlayerKD(results)124 mapRecord[0], mapRecord[1] = player.getPlayerMapRecord(data=results)125 length = results.shape[0]126 return render_template("viewPlayers.html", player=player, stats=stats, tables=[results.to_html(classes="data", index=False)], playerTeams=playerTeams, playerEvents=playerEvents, selectedItems=selectedItems, kills=kills, deaths=deaths, kd=kd, length=length, mapRecord=mapRecord)127@app.route("/matchupPreview", methods=["GET", "POST"])128def matchupPreview():129 selectedItems = ['', '']130 team1 = Team()131 team2 = Team()132 results = stats.getMatchupPreview(team1.name, team2.name)133 if request.method == "POST":134 team1 = Team(request.form.get("team1"))135 team2 = Team(request.form.get("team2"))136 selectedItems[0] = team1.name137 selectedItems[1] = team2.name138 results = stats.getMatchupPreview(team1.name, team2.name)139 return render_template("matchupPreview.html", team1=team1, team2=team2, stats=stats, results=results, selectedItems=selectedItems)140@app.route("/mapPreview", methods=["GET", "POST"])141def mapPreview():142 team1 = Team()143 team2 = Team()144 maps = []145 team1Records = {'wins': [0, 0, 0, 0, 0], 'losses': [0, 0, 0, 0, 0]}146 team2Records = {'wins': [0, 0, 0, 0, 0], 'losses': [0, 0, 0, 0, 0]}147 headToHead = {team1.name: [0, 0, 0, 0, 0], team2.name: [0, 0, 0, 0, 0]}148 selectedItems = ['', '', ['', '', '', '', '']]149 if request.method == "POST":150 team1 = Team(request.form.get('team1'))151 team2 = Team(request.form.get('team2'))152 maps = [request.form.get('map1'),153 request.form.get('map2'),154 request.form.get('map3'),155 request.form.get('map4'),156 request.form.get('map5')]157 selectedItems[0] = team1.name158 selectedItems[1] = team2.name159 for k in range(5):160 selectedItems[2][k] = maps[k]161 team1Records, team2Records, headToHead = stats.getMapPreview(team1.name, team2.name, maps)162 return render_template("mapPreview.html", team1=team1, team2=team2, stats=stats, maps=maps, team1Records=team1Records, team2Records=team2Records, headToHead=headToHead, selectedItems=selectedItems)163@app.route("/teamLeaderboard", methods=["GET", "POST"])164def teamLeaderboard():165 selectedItems = ['Match Win Percent', '', '', '', '']166 results = {}167 if request.method == "POST":168 type = request.form.get('type')169 opponent = request.form.get('opponent')170 event = request.form.get('event')171 mode = request.form.get('mode')172 map = request.form.get('map')173 selectedItems[0] = type174 selectedItems[1] = opponent175 selectedItems[2] = event176 selectedItems[3] = mode177 selectedItems[4] = map178 results = stats.getTeamLeaderboard(type, opponent, event, mode, map)179 results = dict(sorted(results.items(), key=lambda item: item[1], reverse=True))180 if opponent != 'All':181 del results[opponent]182 return render_template("teamLeaderboard.html", stats=stats, selectedItems=selectedItems, results=results)183@app.route("/playerLeaderboard", methods=["GET", "POST"])184def playerLeaderboard():185 results = {}186 selectedItems = ['Kills', '', '', '', '', '']187 types = list(stats.players.columns)188 startIndex = types.index('Score')189 types = types[startIndex:]190 types.remove('Map Result')191 if request.method == 'POST':192 type = request.form.get('type')193 team = request.form.get('team')194 opponent = request.form.get('opponent')195 event = request.form.get('event')196 mode = request.form.get('mode')197 map = request.form.get('map')198 selectedItems[0] = type199 selectedItems[1] = team200 selectedItems[2] = opponent201 selectedItems[3] = event202 selectedItems[4] = mode203 selectedItems[5] = map204 results = stats.getPlayerLeaderboard(type, team, opponent, event, mode, map)205 results = dict(sorted(results.items(), key=lambda item: item[1], reverse=True))206 return render_template("playerLeaderboard.html", stats=stats, results=results, types=types, selectedItems=selectedItems)207@app.route("/records", methods=["GET", "POST"])208def records():209 selectedItems = ['Kills', '', '', '', '', '']210 type = 'Kills'211 types = list(stats.players.columns)212 startIndex = types.index('Score')213 types = types[startIndex:]214 types.remove('Map Result')215 if request.method == 'POST' or request.method == 'GET':216 team = request.form.get('team')217 opponent = request.form.get('opponent')218 event = request.form.get('event')219 mode = request.form.get('mode')220 map = request.form.get('map')221 type = request.form.get('type')222 selectedItems[0] = type223 selectedItems[1] = team224 selectedItems[2] = opponent225 selectedItems[3] = event226 selectedItems[4] = mode227 selectedItems[5] = map228 data = stats.getRecordsRange(team, opponent, event, mode, map)229 if data.shape[0] != 0:230 typeRecords = stats.getRecords(data, type)231 else:232 typeRecords = data233 typeRecords.dropna(how='all', axis=1, inplace=True)234 return render_template("records.html", stats=stats, types=types, type=type, tables=[typeRecords.to_html(classes="data", index=False)], selectedItems=selectedItems)235if __name__ == "__main__":...

Full Screen

Full Screen

AZOWGUI.py

Source:AZOWGUI.py Github

copy

Full Screen

...85 self.__updateLists()86 if self.callbackOnReset != None:87 self.callbackOnReset()88 def __onButtonAddClicked(self):89 for item in self.inputItemsList.selectedItems():90 self.selectedItems.append(item.text())91 self.availableItems.remove(item.text())92 self.__updateLists()93 def __onButtonRemoveClicked(self):94 for item in self.selectedItemsList.selectedItems():95 self.availableItems.append(item.text())96 self.selectedItems.remove(item.text())97 self.__updateLists()98 def setInputItems(self, items):99 self.inputItems = [str(x) for x in items]100 self.__reset()101if __name__ == "__main__":102 a = QApplication(sys.argv)103 owdm = OWOptimizeMe()104 a.setMainWidget(owdm)105 owdm.show()...

Full Screen

Full Screen

Multiselect.ts

Source:Multiselect.ts Github

copy

Full Screen

1import * as _ from 'underscore';2export interface MultiSelectOptionsInterface {3 remoteRequest: any;4 model: any;5 placeholder: string;6 required: boolean;7 label: string;8 preloadOptions?: boolean;9 single?: boolean;10 notFoundText?: string;11 errorMessage?: string;12 addTag?: boolean | ((term: string) => any | Promise<any>);13 isLoading?: boolean;14}15export class MultiSelect {16 remoteRequest: any;17 model: any;18 placeholder: string;19 items: any = [];20 selectedItems: any = [];21 label: string;22 preloadOptions: boolean;23 single: boolean;24 notFoundText: string;25 query: string;26 isInvalid: boolean;27 errorMessage?: string;28 addTag: boolean | ((term: string) => any | Promise<any>);29 isLoading?: boolean;30 constructor(options: MultiSelectOptionsInterface) {31 this.remoteRequest = options.remoteRequest;32 this.model = options.model;33 this.placeholder = options.placeholder;34 this.label = options.label;35 if (options.preloadOptions) { this.preloadOptions = options.preloadOptions; }36 if (options.single) { this.single = options.single; }37 if (options.notFoundText) { this.notFoundText = options.notFoundText; }38 if (options.addTag) { this.addTag = options.addTag; }39 }40 add(itemData): void {41 const model = new this.model(itemData);42 const alreadySelected = _.find(this.selectedItems, (item: any) => itemData.name === item.name);43 if (alreadySelected) { model.disabled = true; }44 this.items.push(model);45 }46 remove(item): void {47 const items = [];48 const selectedItems = [];49 _.each(this.selectedItems, (elem: any) => {50 items.push(elem);51 if (item.name !== elem.name) {52 selectedItems.push(elem);53 }54 });55 this.updateSelection(selectedItems);56 }57 updateSelection(selectedItems?): void {58 if (!selectedItems) { selectedItems = _.clone(this.selectedItems); }59 if (!selectedItems) { return; }60 if (!this.single) {61 this.items = [];62 this.selectedItems = [];63 this.addPreselectedItemsList(selectedItems);64 } else {65 this.setSingleItem(selectedItems);66 }67 }68 addPreselectedItemsList(itemsList): void {69 itemsList.forEach((elem) => {70 const itemModel = new this.model(elem);71 this.items.push(itemModel);72 this.selectedItems.push(itemModel);73 } );74 }75 setSingleItem(item): boolean {76 if (!item) { return false; }77 this.selectedItems = this.items.find(x => x.name === item.name);78 if (!this.selectedItems) {79 const itemModel = new this.model(item);80 this.items.push(itemModel);81 this.selectedItems = itemModel;82 }83 }84 getList(): any {85 return this.selectedItems;86 }87 isSingleSelect(): boolean {88 return !!this.single;89 }90 getNotFoundText(): string {91 if (this.query) {92 return 'No Items Found...';93 } else {94 return this.notFoundText;95 }96 }97 setInvalidState(message?: string): void {98 this.isInvalid = true;99 this.errorMessage = message;100 }101 clearInvalidState(): void {102 this.isInvalid = false;103 this.errorMessage = null;104 }105 isEmpty(): boolean {106 return this.selectedItems.length === 0;107 }...

Full Screen

Full Screen

baseselectionmodel.py

Source:baseselectionmodel.py Github

copy

Full Screen

12from PySide import QtGui34#from pytk.util.logutils import logMsg5from pytk.util.sysutils import getCaller67class BaseSelectionModel(QtGui.QItemSelectionModel):89 def __init__(self, model, parent=None):10 super(BaseSelectionModel, self).__init__(model, parent)1112# self.selectedItems = []13 self.itemPressed = False1415 self.selectionChanged.connect(self.onSelectionChanged)1617 def onSelectionChanged(self, selected, deselected):1819 caller = getCaller()2021 #print "onSelectionChanged", caller2223 if (caller is None) or (caller == "mousePressEvent"):24 self.itemPressed = True2526# self.updateSelection(selected, deselected)272829# def clearSelection(self):30# logMsg(log='all')31#32# QtGui.QItemSelectionModel.clearSelection(self)33# self.selectedItems = []3435# def clear(self, *args, **kwargs):36#37# QtGui.QItemSelectionModel.clear(self)38# self.selectedItems = []3940# def updateSelection(self, selected, deselected):41# logMsg(log='all')42#43# curntModel = self.model()44#45# selectedItems = []46# deselectedItems = []47#48# for index in deselected.indexes():49#50# if index.column() > 0:51# continue52#53# item = curntModel.itemFromIndex(index)54#55# print type(self.selectedItems)56# try:57# self.selectedItems.remove(item)58# except ValueError, msg:59# logMsg("{0} : {1} not in selectedItems".format(msg, item) , warning=True)60# else:61# deselectedItems.append(item)62#63# for index in selected.indexes():64#65# if index.column() > 0:66# continue67#68# item = curntModel.itemFromIndex(index)69#70# self.selectedItems.append(item)71# selectedItems.append(item)72#73# return selectedItems, deselectedItems74757677 def __repr__(self):7879 try:80 sRepr = ('{0}( "{1}" )'.format(self.__class__.__name__, self.objectName()))81 except:82 sRepr = self.__class__.__module__ + "." + self.__class__.__name__83 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful