From c8159483bd3c773801485060c64b2c7f0f95be2d Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Thu, 5 Mar 2020 15:39:26 -0500 Subject: [PATCH 1/7] Removes Waffle board badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c3bc8e..0dbdec2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Trapp -[![Build Status](https://travis-ci.org/matt-bernhardt/trapp.svg)](https://travis-ci.org/matt-bernhardt/trapp) [![Stories in Ready](https://badge.waffle.io/matt-bernhardt/trapp.svg?label=ready&title=Ready)](http://waffle.io/matt-bernhardt/trapp) [![Coverage Status](https://coveralls.io/repos/matt-bernhardt/trapp/badge.svg?branch=master&service=github)](https://coveralls.io/github/matt-bernhardt/trapp?branch=master) [![Code Climate](https://codeclimate.com/github/matt-bernhardt/trapp/badges/gpa.svg)](https://codeclimate.com/github/matt-bernhardt/trapp) +[![Build Status](https://travis-ci.org/matt-bernhardt/trapp.svg)](https://travis-ci.org/matt-bernhardt/trapp) [![Coverage Status](https://coveralls.io/repos/matt-bernhardt/trapp/badge.svg?branch=master&service=github)](https://coveralls.io/github/matt-bernhardt/trapp?branch=master) [![Code Climate](https://codeclimate.com/github/matt-bernhardt/trapp/badges/gpa.svg)](https://codeclimate.com/github/matt-bernhardt/trapp) Trapp is a Python project for linking, analyzing, and extending soccer data. From add3829bcaabd6633176cdf09cfb3a909d6216b2 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Fri, 6 Mar 2020 22:37:37 -0500 Subject: [PATCH 2/7] Removes unneeded future loads, changes unicode() to str() --- tests/conftest.py | 1 - tests/test_checker.py | 1 - tests/test_checkgame.py | 1 - tests/test_combo.py | 1 - tests/test_competition.py | 1 - tests/test_compilegame.py | 1 - tests/test_compileteammate.py | 1 - tests/test_database.py | 1 - tests/test_game.py | 1 - tests/test_gameevent.py | 1 - tests/test_gameminute.py | 1 - tests/test_gamestat.py | 1 - tests/test_importer.py | 3 +-- tests/test_log.py | 1 - tests/test_player.py | 1 - tests/test_record.py | 1 - tests/test_season.py | 1 - tests/test_spreadsheet.py | 1 - tests/test_team.py | 1 - tests/test_venue.py | 1 - 20 files changed, 1 insertion(+), 21 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a369e61..caa8ee3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import pytest import os diff --git a/tests/test_checker.py b/tests/test_checker.py index b898fd2..a5f2f8f 100644 --- a/tests/test_checker.py +++ b/tests/test_checker.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.log import Log from trapp.checker import Checker diff --git a/tests/test_checkgame.py b/tests/test_checkgame.py index 7f776dd..2078851 100644 --- a/tests/test_checkgame.py +++ b/tests/test_checkgame.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.log import Log from trapp.check_games import CheckerGames diff --git a/tests/test_combo.py b/tests/test_combo.py index 7c813c2..a333965 100644 --- a/tests/test_combo.py +++ b/tests/test_combo.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.combo import Combo from trapp.log import Log diff --git a/tests/test_competition.py b/tests/test_competition.py index b54d714..0c9ecc0 100644 --- a/tests/test_competition.py +++ b/tests/test_competition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.competition import Competition from trapp.log import Log diff --git a/tests/test_compilegame.py b/tests/test_compilegame.py index abab8d9..9bb7a90 100644 --- a/tests/test_compilegame.py +++ b/tests/test_compilegame.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.log import Log from trapp.compile_game import CompilerGames diff --git a/tests/test_compileteammate.py b/tests/test_compileteammate.py index a286985..14edcd8 100644 --- a/tests/test_compileteammate.py +++ b/tests/test_compileteammate.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.log import Log from trapp.compile_teammate import CompilerTeammates diff --git a/tests/test_database.py b/tests/test_database.py index ae551e1..ae05ae0 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.database import Database diff --git a/tests/test_game.py b/tests/test_game.py index 494086f..d19c517 100644 --- a/tests/test_game.py +++ b/tests/test_game.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.game import Game from trapp.log import Log diff --git a/tests/test_gameevent.py b/tests/test_gameevent.py index c6435aa..b557023 100644 --- a/tests/test_gameevent.py +++ b/tests/test_gameevent.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.gameevent import GameEvent from trapp.log import Log diff --git a/tests/test_gameminute.py b/tests/test_gameminute.py index f97ddea..655e8e7 100644 --- a/tests/test_gameminute.py +++ b/tests/test_gameminute.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.gameminute import GameMinute from trapp.log import Log diff --git a/tests/test_gamestat.py b/tests/test_gamestat.py index 1a21c4d..6c82470 100644 --- a/tests/test_gamestat.py +++ b/tests/test_gamestat.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.gamestat import GameStat from trapp.log import Log diff --git a/tests/test_importer.py b/tests/test_importer.py index 2126aa3..32fec6c 100644 --- a/tests/test_importer.py +++ b/tests/test_importer.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest import mock from trapp.log import Log @@ -162,7 +161,7 @@ def test_importer_parseMinuteDoesNothing(excel): log = Log('test.log') importer = ImporterLineups(excel, log) assert importer.parseMinute(15) == 15 - assert importer.parseMinute(unicode(45)) == 45 + assert importer.parseMinute(str(45)) == 45 assert importer.parseMinute('89') == 89 diff --git a/tests/test_log.py b/tests/test_log.py index 98a41b8..6a76e9c 100644 --- a/tests/test_log.py +++ b/tests/test_log.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.log import Log diff --git a/tests/test_player.py b/tests/test_player.py index 0ca7c01..f279d8f 100644 --- a/tests/test_player.py +++ b/tests/test_player.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.player import Player from trapp.log import Log diff --git a/tests/test_record.py b/tests/test_record.py index a70cb8f..7b3a8e7 100644 --- a/tests/test_record.py +++ b/tests/test_record.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.record import Record import datetime diff --git a/tests/test_season.py b/tests/test_season.py index b1f6794..ff1fa42 100644 --- a/tests/test_season.py +++ b/tests/test_season.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.season import Season from trapp.log import Log diff --git a/tests/test_spreadsheet.py b/tests/test_spreadsheet.py index 3869339..b1580d9 100644 --- a/tests/test_spreadsheet.py +++ b/tests/test_spreadsheet.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import xlrd from trapp.spreadsheet import Spreadsheet diff --git a/tests/test_team.py b/tests/test_team.py index f6b984f..500b639 100644 --- a/tests/test_team.py +++ b/tests/test_team.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.team import Team from trapp.log import Log diff --git a/tests/test_venue.py b/tests/test_venue.py index a31885c..d7f7ffc 100644 --- a/tests/test_venue.py +++ b/tests/test_venue.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import pytest from trapp.venue import Venue from trapp.log import Log From ccc8503498b20304d53e85028b7b743adaaac745 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Fri, 6 Mar 2020 22:46:54 -0500 Subject: [PATCH 3/7] More 2to3 rewrites --- trapp/__init__.py | 1 - trapp/check_games.py | 1 - trapp/checker.py | 1 - trapp/combo.py | 1 - trapp/command_line.py | 23 +++++++++++------------ trapp/competition.py | 1 - trapp/compile_game.py | 5 ++--- trapp/compile_teammate.py | 7 +++---- trapp/compiler.py | 1 - trapp/database.py | 1 - trapp/game.py | 3 +-- trapp/gameevent.py | 1 - trapp/gameminute.py | 1 - trapp/gamestat.py | 1 - trapp/import_game.py | 1 - trapp/import_goal.py | 9 ++++----- trapp/import_lineup.py | 1 - trapp/import_player.py | 1 - trapp/importer.py | 9 ++++----- trapp/log.py | 1 - trapp/player.py | 3 +-- trapp/record.py | 1 - trapp/season.py | 1 - trapp/spreadsheet.py | 5 ++--- trapp/team.py | 1 - trapp/venue.py | 1 - 26 files changed, 28 insertions(+), 54 deletions(-) diff --git a/trapp/__init__.py b/trapp/__init__.py index 139759b..40a96af 100644 --- a/trapp/__init__.py +++ b/trapp/__init__.py @@ -1,2 +1 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import diff --git a/trapp/check_games.py b/trapp/check_games.py index 9ea198e..52c372e 100644 --- a/trapp/check_games.py +++ b/trapp/check_games.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.checker import Checker from trapp.competition import Competition diff --git a/trapp/checker.py b/trapp/checker.py index 64ad611..2471ffd 100644 --- a/trapp/checker.py +++ b/trapp/checker.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.database import Database diff --git a/trapp/combo.py b/trapp/combo.py index d6a7643..9c2b844 100644 --- a/trapp/combo.py +++ b/trapp/combo.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record diff --git a/trapp/command_line.py b/trapp/command_line.py index 0811acb..28e4ffb 100644 --- a/trapp/command_line.py +++ b/trapp/command_line.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import argparse from trapp.database import Database from trapp.log import Log @@ -22,20 +21,20 @@ def checkDB(args): # print out credentials in verbose mode if (args.verbose): print('Credentials:') - print('dbuser: ' + str(connection['dbuser'])) - print('dbpwd: ' + str(connection['dbpwd'])) - print('dbhost: ' + str(connection['dbhost'])) - print('dbschema: ' + str(connection['dbschema'])) + print(('dbuser: ' + str(connection['dbuser']))) + print(('dbpwd: ' + str(connection['dbpwd']))) + print(('dbhost: ' + str(connection['dbhost']))) + print(('dbschema: ' + str(connection['dbschema']))) print('') # Try to establish the connection db.connect() # print result - print(str(db.cnx)) + print((str(db.cnx))) if (args.verbose): - print(str(db.cursor)) - print('Warnings: ' + str(db.warnings())) + print((str(db.cursor))) + print(('Warnings: ' + str(db.warnings()))) def checkGames(args): @@ -89,7 +88,7 @@ def compileYears(): def importGames(infile): # Feedback, setup - print('Importing games from ' + str(infile)) + print(('Importing games from ' + str(infile))) log = Log('trapp-import-games.log') importer = ImporterGames(infile, log) @@ -114,7 +113,7 @@ def importGames(infile): def importGoals(infile): # Feedback, setup - print('Importing goals from ' + str(infile)) + print(('Importing goals from ' + str(infile))) log = Log('trapp-import-goals.log') importer = ImporterGoals(infile, log) @@ -142,7 +141,7 @@ def importLineups(infile): # TODO: Lookup teams in a specified league and year? # TODO: Iterate over team list, with separate Importer for each? # Feedback, setup - print('Importing lineups from ' + str(infile)) + print(('Importing lineups from ' + str(infile))) log = Log('trapp-import-lineups.log') importer = ImporterLineups(infile, log) @@ -171,7 +170,7 @@ def importLineups(infile): def importPlayers(infile): # Feedback, setup - print('Importing players from ' + str(infile)) + print(('Importing players from ' + str(infile))) log = Log('trapp-import-players.log') importer = ImporterPlayers(infile, log) diff --git a/trapp/competition.py b/trapp/competition.py index deb81e7..09a4ab9 100644 --- a/trapp/competition.py +++ b/trapp/competition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record diff --git a/trapp/compile_game.py b/trapp/compile_game.py index 8c732c3..02404c8 100644 --- a/trapp/compile_game.py +++ b/trapp/compile_game.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import time from trapp.compiler import Compiler from trapp.gameevent import GameEvent @@ -46,7 +45,7 @@ def doCompile(self): # 1) Assemble list of player appearances self.appearances = self.getAppearanceList() - print("Processing " + str(len(self.appearances)) + " records") + print(("Processing " + str(len(self.appearances)) + " records")) self.log.message(str(len(self.appearances)) + " records\n") # 2) For each appearance: @@ -96,5 +95,5 @@ def getEventSummary(self, item): temp = ge.summarizeEvents(item, self.log) if(len(temp) == 0): temp = [{'Goals': 0, 'Ast': 0}] - item = dict(item.items() + temp[0].items()) + item = dict(list(item.items()) + list(temp[0].items())) return item diff --git a/trapp/compile_teammate.py b/trapp/compile_teammate.py index c7b0936..5e64ab0 100644 --- a/trapp/compile_teammate.py +++ b/trapp/compile_teammate.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import import time from trapp.combo import Combo from trapp.compiler import Compiler @@ -33,7 +32,7 @@ def doCompile(self): # Second, for each team-season: for item in self.seasons: - print(str(item)) + print((str(item))) self.log.message(str(item)) # Get the list of players to have appeared in this season @@ -47,12 +46,12 @@ def doCompile(self): continue self.log.message(str(len(self.players)) + ' players this season') - print(str(len(self.players)) + ' players') + print((str(len(self.players)) + ' players')) # Iterate over the list of players, building player pairs self.combos = self.assembleCombos(self.players) self.log.message(str(len(self.combos)) + ' combos this season') - print(str(len(self.combos)) + ' combos') + print((str(len(self.combos)) + ' combos')) # Make sure each pair is recorded initially self.lookupCombos() diff --git a/trapp/compiler.py b/trapp/compiler.py index dde4b41..41a5b05 100644 --- a/trapp/compiler.py +++ b/trapp/compiler.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import class Compiler(): diff --git a/trapp/database.py b/trapp/database.py index 53f287e..35eeb34 100644 --- a/trapp/database.py +++ b/trapp/database.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from mysql import connector import trapp.connection as connection import time diff --git a/trapp/game.py b/trapp/game.py index f9d69b2..b59deb0 100644 --- a/trapp/game.py +++ b/trapp/game.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record @@ -111,7 +110,7 @@ def saveDict(self, newData, log): # - ?? # Check if dictionary contains a gameID - if ('MatchID' in newData.keys()): + if ('MatchID' in list(newData.keys())): # Update log.message('MatchID provided') sql = ('UPDATE tbl_games SET ' diff --git a/trapp/gameevent.py b/trapp/gameevent.py index f6e8247..a7bbe4d 100644 --- a/trapp/gameevent.py +++ b/trapp/gameevent.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record diff --git a/trapp/gameminute.py b/trapp/gameminute.py index 8a0f915..4d4e9b6 100644 --- a/trapp/gameminute.py +++ b/trapp/gameminute.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record diff --git a/trapp/gamestat.py b/trapp/gamestat.py index 1bf290a..63fead2 100644 --- a/trapp/gamestat.py +++ b/trapp/gamestat.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record diff --git a/trapp/import_game.py b/trapp/import_game.py index 53163d8..74955ac 100644 --- a/trapp/import_game.py +++ b/trapp/import_game.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.importer import Importer from trapp.game import Game diff --git a/trapp/import_goal.py b/trapp/import_goal.py index 6bd06f6..3b310c5 100644 --- a/trapp/import_goal.py +++ b/trapp/import_goal.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.importer import Importer from trapp.game import Game from trapp.gameevent import GameEvent @@ -87,10 +86,10 @@ def correctValues(self): def disambiguatePlayers(self, record, result): # Ask user to provide player ID - print('\nPlayerID lookup of _' + str(record['playername']) + '_' + - ' failed with ' + str(len(result)) + ' records\n') - print(str(record)) - newID = int(raw_input('Player ID - provide null or 0 to skip: ')) + print(('\nPlayerID lookup of _' + str(record['playername']) + '_' + + ' failed with ' + str(len(result)) + ' records\n')) + print((str(record))) + newID = int(input('Player ID - provide null or 0 to skip: ')) return newID diff --git a/trapp/import_lineup.py b/trapp/import_lineup.py index ec5b743..48d8914 100644 --- a/trapp/import_lineup.py +++ b/trapp/import_lineup.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.importer import Importer from trapp.game import Game from trapp.gameminute import GameMinute diff --git a/trapp/import_player.py b/trapp/import_player.py index 31af05a..6af87f6 100644 --- a/trapp/import_player.py +++ b/trapp/import_player.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.importer import Importer from trapp.player import Player diff --git a/trapp/importer.py b/trapp/importer.py index b231658..4ea1c53 100644 --- a/trapp/importer.py +++ b/trapp/importer.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.spreadsheet import Spreadsheet from trapp.game import Game from trapp.team import Team @@ -150,10 +149,10 @@ def reportStatus(self): self.log.message(str(self.updated) + ' updated') self.log.message(str(self.skipped) + ' skipped') self.log.message(str(self.errored) + ' errored') - print(str(self.imported) + ' imported') - print(str(self.updated) + ' updated') - print(str(self.skipped) + ' skipped') - print(str(self.errored) + ' errored') + print((str(self.imported) + ' imported')) + print((str(self.updated) + ' updated')) + print((str(self.skipped) + ' skipped')) + print((str(self.errored) + ' errored')) if (len(self.missing) > 0): self.log.message('\n') self.log.message(str(len(self.missing)) + ' missing records:') diff --git a/trapp/log.py b/trapp/log.py index 033dd89..c68ef3a 100644 --- a/trapp/log.py +++ b/trapp/log.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import class Log(): diff --git a/trapp/player.py b/trapp/player.py index 8acf71c..4584447 100644 --- a/trapp/player.py +++ b/trapp/player.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record @@ -161,7 +160,7 @@ def saveDict(self, newData, log): 'DOB' ] - if ('PlayerID' in newData.keys()): + if ('PlayerID' in list(newData.keys())): # Update log.message(' ...Updating') diff --git a/trapp/record.py b/trapp/record.py index 4912748..f9c105a 100644 --- a/trapp/record.py +++ b/trapp/record.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.database import Database diff --git a/trapp/season.py b/trapp/season.py index c26c9fc..9376520 100644 --- a/trapp/season.py +++ b/trapp/season.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record diff --git a/trapp/spreadsheet.py b/trapp/spreadsheet.py index 35093e7..4522cc4 100644 --- a/trapp/spreadsheet.py +++ b/trapp/spreadsheet.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from xlrd import open_workbook, xldate_as_tuple @@ -11,8 +10,8 @@ def __init__(self, file): def buildRecords(self): self.records = [] self.sheet = self.buildSheet() - for row in xrange(1, self.sheet.nrows): - d = {self.fields[col]: self.sheet.cell(row, col).value for col in xrange(self.sheet.ncols)} + for row in range(1, self.sheet.nrows): + d = {self.fields[col]: self.sheet.cell(row, col).value for col in range(self.sheet.ncols)} # d['MatchTime'] = self.recoverDate(d['MatchTime']) self.records.append(d) return self.records diff --git a/trapp/team.py b/trapp/team.py index 15f290a..c888d28 100644 --- a/trapp/team.py +++ b/trapp/team.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record diff --git a/trapp/venue.py b/trapp/venue.py index 2a7c639..5c6c61b 100644 --- a/trapp/venue.py +++ b/trapp/venue.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from trapp.record import Record From 80e044fcca7122ac95471a6fdc0773e5dba4634e Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Fri, 6 Mar 2020 22:52:47 -0500 Subject: [PATCH 4/7] swap __builtin__ to builtins --- tests/test_importer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_importer.py b/tests/test_importer.py index 32fec6c..1d07c84 100644 --- a/tests/test_importer.py +++ b/tests/test_importer.py @@ -50,7 +50,7 @@ def test_importer_checkFields(excel): def test_importer_disambiguatePlayers(excel): log = Log('test.log') importer = ImporterGoals(excel, log) - with mock.patch('__builtin__.raw_input', return_value=1234): + with mock.patch('builtins.raw_input', return_value=1234): record = { 'playername': 'Bogus Player' } @@ -94,7 +94,7 @@ def test_importer_lookupPlayerID_valid(excel): log = Log('test.log') importer = ImporterGoals(excel, log) # Invalid records get run through disambiguation - with mock.patch('__builtin__.raw_input', return_value=0): + with mock.patch('builtins.raw_input', return_value=0): event = {'playername': 'Invalid Player', 'TeamID': 2, 'GameID': 1, 'Event': 1} assert importer.lookupPlayerID(event) is False assert importer.skipped == 1 From 95f4d11132af400c2b7886a6c95662529d6e76b6 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Sun, 8 Mar 2020 13:33:52 -0400 Subject: [PATCH 5/7] Fixes line length --- trapp/spreadsheet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trapp/spreadsheet.py b/trapp/spreadsheet.py index 4522cc4..7d0bdf8 100644 --- a/trapp/spreadsheet.py +++ b/trapp/spreadsheet.py @@ -11,7 +11,8 @@ def buildRecords(self): self.records = [] self.sheet = self.buildSheet() for row in range(1, self.sheet.nrows): - d = {self.fields[col]: self.sheet.cell(row, col).value for col in range(self.sheet.ncols)} + d = {self.fields[col]: self.sheet.cell(row, col).value + for col in range(self.sheet.ncols)} # d['MatchTime'] = self.recoverDate(d['MatchTime']) self.records.append(d) return self.records From 018d1865829700933fe70963be095677f27f7d97 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Sun, 8 Mar 2020 13:45:09 -0400 Subject: [PATCH 6/7] Better code comments in team.lookupID --- trapp/team.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/trapp/team.py b/trapp/team.py index c888d28..70b5c03 100644 --- a/trapp/team.py +++ b/trapp/team.py @@ -5,11 +5,15 @@ class Team(Record): def lookupID(self, data, log): - # Check for required parameters + # This takes a dictionary and validates it against existing records. + # Do we already have a record of this team? + # The data must have the following keys: + # - teamname (string - the colloquial name of the team, + # i.e. "Columbus Crew") required = ['teamname'] self.checkData(data, required) - # see if any team matches this name + # See if any team matches this name sql = ('SELECT ID ' 'FROM tbl_teams ' 'WHERE teamname = %s') From a72e446713feedd8a29587805199140dc1a3222b Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Fri, 6 Mar 2020 23:10:07 -0500 Subject: [PATCH 7/7] Reworks mocked input --- tests/test_importer.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/test_importer.py b/tests/test_importer.py index 1d07c84..e3c2f56 100644 --- a/tests/test_importer.py +++ b/tests/test_importer.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import pytest -import mock +from io import StringIO from trapp.log import Log from trapp.importer import Importer from trapp.import_game import ImporterGames @@ -47,14 +47,19 @@ def test_importer_checkFields(excel): assert 'missing the following columns' in str(excinfo.value) -def test_importer_disambiguatePlayers(excel): +def test_importer_disambiguatePlayers(excel, monkeypatch): + # Mocked user input + mock_input = StringIO(u'1234\n') + # Sample record + record = { + 'playername': 'Bogus Player' + } + # Run test log = Log('test.log') importer = ImporterGoals(excel, log) - with mock.patch('builtins.raw_input', return_value=1234): - record = { - 'playername': 'Bogus Player' - } - assert importer.disambiguatePlayers(record, [0]) == 1234 + monkeypatch.setattr('sys.stdin', mock_input) + result = importer.disambiguatePlayers(record, [0]) + assert result == 1234 def test_importer_generic_importRecord(excel): @@ -90,14 +95,17 @@ def test_importer_lookupPlayerID_owngoal(excel): assert importer.skipped == 0 -def test_importer_lookupPlayerID_valid(excel): +def test_importer_lookupPlayerID_valid(excel, monkeypatch): + # Mock user input + mock_input = StringIO(u'0\n') + # Sample record + event = {'playername': 'Invalid Player', 'TeamID': 2, 'GameID': 1, 'Event': 1} + # Run test log = Log('test.log') importer = ImporterGoals(excel, log) - # Invalid records get run through disambiguation - with mock.patch('builtins.raw_input', return_value=0): - event = {'playername': 'Invalid Player', 'TeamID': 2, 'GameID': 1, 'Event': 1} - assert importer.lookupPlayerID(event) is False - assert importer.skipped == 1 + monkeypatch.setattr('sys.stdin', mock_input) + assert importer.lookupPlayerID(event) is False + assert importer.skipped == 1 def test_importer_lookupTeamID(excel):