Skip to content

Commit

Permalink
Merge pull request #129 from matt-bernhardt/2to3
Browse files Browse the repository at this point in the history
Attempts adding python3 support (finally)
  • Loading branch information
matt-bernhardt authored Mar 8, 2020
2 parents 5a208d5 + a72e446 commit 56801e0
Show file tree
Hide file tree
Showing 47 changed files with 58 additions and 91 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
import pytest
import os

Expand Down
1 change: 0 additions & 1 deletion tests/test_checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.log import Log
from trapp.checker import Checker
Expand Down
1 change: 0 additions & 1 deletion tests/test_checkgame.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/test_combo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.combo import Combo
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_competition.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.competition import Competition
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_compilegame.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.log import Log
from trapp.compile_game import CompilerGames

Expand Down
1 change: 0 additions & 1 deletion tests/test_compileteammate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.log import Log
from trapp.compile_teammate import CompilerTeammates

Expand Down
1 change: 0 additions & 1 deletion tests/test_database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.database import Database


Expand Down
1 change: 0 additions & 1 deletion tests/test_game.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.game import Game
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_gameevent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.gameevent import GameEvent
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_gameminute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.gameminute import GameMinute
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_gamestat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.gamestat import GameStat
from trapp.log import Log
Expand Down
37 changes: 22 additions & 15 deletions tests/test_importer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
import mock
from io import StringIO
from trapp.log import Log
from trapp.importer import Importer
from trapp.import_game import ImporterGames
Expand Down Expand Up @@ -48,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('__builtin__.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):
Expand Down Expand Up @@ -91,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('__builtin__.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):
Expand Down Expand Up @@ -162,7 +169,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


Expand Down
1 change: 0 additions & 1 deletion tests/test_log.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.log import Log


Expand Down
1 change: 0 additions & 1 deletion tests/test_player.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.player import Player
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_record.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.record import Record
import datetime
Expand Down
1 change: 0 additions & 1 deletion tests/test_season.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.season import Season
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_spreadsheet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import xlrd
from trapp.spreadsheet import Spreadsheet

Expand Down
1 change: 0 additions & 1 deletion tests/test_team.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.team import Team
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion tests/test_venue.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import pytest
from trapp.venue import Venue
from trapp.log import Log
Expand Down
1 change: 0 additions & 1 deletion trapp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
1 change: 0 additions & 1 deletion trapp/check_games.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.checker import Checker
from trapp.competition import Competition

Expand Down
1 change: 0 additions & 1 deletion trapp/checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.database import Database


Expand Down
1 change: 0 additions & 1 deletion trapp/combo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.record import Record


Expand Down
23 changes: 11 additions & 12 deletions trapp/command_line.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import argparse
from trapp.database import Database
from trapp.log import Log
Expand All @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion trapp/competition.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.record import Record


Expand Down
5 changes: 2 additions & 3 deletions trapp/compile_game.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import time
from trapp.compiler import Compiler
from trapp.gameevent import GameEvent
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
7 changes: 3 additions & 4 deletions trapp/compile_teammate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import time
from trapp.combo import Combo
from trapp.compiler import Compiler
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
1 change: 0 additions & 1 deletion trapp/compiler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import


class Compiler():
Expand Down
1 change: 0 additions & 1 deletion trapp/database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from mysql import connector
import trapp.connection as connection
import time
Expand Down
3 changes: 1 addition & 2 deletions trapp/game.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.record import Record


Expand Down Expand Up @@ -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 '
Expand Down
1 change: 0 additions & 1 deletion trapp/gameevent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.record import Record


Expand Down
1 change: 0 additions & 1 deletion trapp/gameminute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.record import Record


Expand Down
1 change: 0 additions & 1 deletion trapp/gamestat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.record import Record


Expand Down
1 change: 0 additions & 1 deletion trapp/import_game.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from trapp.importer import Importer
from trapp.game import Game

Expand Down
Loading

0 comments on commit 56801e0

Please sign in to comment.