From 802a205e100b0ab826d56a9091b41a710ec71539 Mon Sep 17 00:00:00 2001 From: Michal Zimniewicz Date: Sun, 9 Oct 2016 12:27:23 +0200 Subject: adjust super() calls to python2 --- ql/lineup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ql/lineup.py b/ql/lineup.py index b0d5847..c201d4b 100644 --- a/ql/lineup.py +++ b/ql/lineup.py @@ -38,7 +38,7 @@ class TeamInSegment(object): class HomeTeamInSegment(TeamInSegment): def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) + super(HomeTeamInSegment, self).__init__(*args, **kwargs) def get_paired_players_fields(self): return [ @@ -56,7 +56,7 @@ class HomeTeamInSegment(TeamInSegment): class AwayTeamInSegment(TeamInSegment): def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) + super(AwayTeamInSegment, self).__init__(*args, **kwargs) def get_paired_players_fields(self): return [ -- cgit v1.2.3 From ac6d5ebbed923ec7e3ded5c97d55ad2c0ac14f99 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 10 Oct 2016 13:19:25 +0200 Subject: alias raw_input() as input() for python2 --- ql/console.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ql/console.py b/ql/console.py index 0c741ca..dede956 100755 --- a/ql/console.py +++ b/ql/console.py @@ -22,6 +22,12 @@ class Console(object): lineup = self.get_lineup(table) print(lineup.info) print() + # Python 2.x workaround + global input + try: + input = raw_input + except NameError: + pass # if raw_input is not defined (Python 3.x), ignore it for team in lineup.teams: Completer.install_new_completer(team.player_names) for pair in team.pairs: -- cgit v1.2.3 From 1278ce8686853ec67b1359435d9d2ae1981b5d54 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 10 Oct 2016 16:12:23 +0200 Subject: encoding readline completer options in case Python2 unicode strings are involved --- ql/completer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ql/completer.py b/ql/completer.py index a9b7d8d..89920d4 100644 --- a/ql/completer.py +++ b/ql/completer.py @@ -1,4 +1,5 @@ import readline +import sys class Completer(object): @@ -10,8 +11,15 @@ class Completer(object): readline.set_completer_delims('') # allow options with whitespace readline.parse_and_bind('tab: complete') + def __encode_completion_string(self, s): + try: + return s.encode(sys.stdin.encoding) if isinstance(s, unicode) else s + except NameError: # Python 3.x does not have a 'unicode' type + pass + return s + def __init__(self, options): - self.options = options + self.options = [self.__encode_completion_string(s) for s in options] def complete(self, text, state): text = text.lower() -- cgit v1.2.3 From e0ac2a81cb35d8c005d0e4b7846a2eca3dca4c31 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 10 Oct 2016 16:15:33 +0200 Subject: fun fact: `print()` in Python2 prints out "()" --- ql/console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/console.py b/ql/console.py index dede956..6751b83 100755 --- a/ql/console.py +++ b/ql/console.py @@ -21,7 +21,7 @@ class Console(object): def process_table(self, table): lineup = self.get_lineup(table) print(lineup.info) - print() + print('') # Python 2.x workaround global input try: -- cgit v1.2.3 From 70f771d2ab31847333b2c438466fe35895bc24db Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 10 Oct 2016 16:17:39 +0200 Subject: clearing up Pair info for printing purposes --- ql/lineup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/lineup.py b/ql/lineup.py index c201d4b..688825b 100644 --- a/ql/lineup.py +++ b/ql/lineup.py @@ -95,7 +95,7 @@ class Pair(object): return 'Team: %s - %s - %s' % ( self.team.name, self.label, - [ p.info if p is not None else '' for p in self.players ] + ', '.join([ p.info if p is not None else '' for p in self.players ]) ) def set_player(self, name): -- cgit v1.2.3 From 73903fbae90953572241f96b0c25a89a5142abf2 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 26 Feb 2017 14:59:03 +0100 Subject: Versioned dependencies in requirements files --- requirements-linux.txt | 6 +++--- requirements-windows.txt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements-linux.txt b/requirements-linux.txt index 02377be..7be7072 100644 --- a/requirements-linux.txt +++ b/requirements-linux.txt @@ -1,3 +1,3 @@ -django -mysqlclient -readline +django==1.10 +mysqlclient==1.3 +readline==6 diff --git a/requirements-windows.txt b/requirements-windows.txt index 48b847f..dc45013 100644 --- a/requirements-windows.txt +++ b/requirements-windows.txt @@ -1,2 +1,2 @@ -django -pyreadline +django==1.10 +pyreadline==2 -- cgit v1.2.3