From 424afcfad353871cfab5b477aef45f501aff1ff5 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Wed, 24 May 2017 17:44:31 +0300 Subject: [PATCH] 2to3 on pysollib/tile/se*.py --- pysollib/tile/selectcardset.py | 26 +++++++++++++------------- pysollib/tile/selectgame.py | 31 ++++++++++++++++++------------- pysollib/tile/selecttile.py | 17 +++++++++-------- pysollib/tile/selecttree.py | 2 +- 4 files changed, 41 insertions(+), 35 deletions(-) diff --git a/pysollib/tile/selectcardset.py b/pysollib/tile/selectcardset.py index 9076b7f2..20c07bf6 100644 --- a/pysollib/tile/selectcardset.py +++ b/pysollib/tile/selectcardset.py @@ -26,7 +26,7 @@ __all__ = ['SelectCardsetDialogWithPreview'] # imports import os from six.moves import tkinter -import ttk +from . import ttk # PySol imports from pysollib.mygettext import _ @@ -36,10 +36,10 @@ from pysollib.resource import CSI # Toolkit imports from pysollib.ui.tktile.tkutil import loadImage -from tkwidget import MfxDialog, MfxScrolledCanvas, PysolScale +from .tkwidget import MfxDialog, MfxScrolledCanvas, PysolScale from pysollib.ui.tktile.tkcanvas import MfxCanvasImage -from selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode -from selecttree import SelectDialogTreeData, SelectDialogTreeCanvas +from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode +from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas # ************************************************************************ @@ -74,7 +74,7 @@ class SelectCardsetData(SelectDialogTreeData): None, None, _("(no cardsets)"), key=None), ] # select_by_type = None - items = CSI.TYPE.items() + items = list(CSI.TYPE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -87,7 +87,7 @@ class SelectCardsetData(SelectDialogTreeData): None, _("by Type"), tuple(nodes), expanded=1) # select_by_style = None - items = CSI.STYLE.items() + items = list(CSI.STYLE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -103,7 +103,7 @@ class SelectCardsetData(SelectDialogTreeData): None, _("by Style"), tuple(nodes)) # select_by_nationality = None - items = CSI.NATIONALITY.items() + items = list(CSI.NATIONALITY.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -121,7 +121,7 @@ class SelectCardsetData(SelectDialogTreeData): None, _("by Nationality"), tuple(nodes)) # select_by_date = None - items = CSI.DATE.items() + items = list(CSI.DATE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -136,7 +136,7 @@ class SelectCardsetData(SelectDialogTreeData): select_by_date = SelectCardsetNode( None, _("by Date"), tuple(nodes)) # - self.rootnodes = filter(None, ( + self.rootnodes = [_f for _f in ( SelectCardsetNode( None, _("All Cardsets"), lambda cs: 1, expanded=len(self.all_objects) <= 12), @@ -162,7 +162,7 @@ class SelectCardsetData(SelectDialogTreeData): select_by_style, select_by_date, select_by_nationality, - )) + ) if _f] class SelectCardsetByTypeData(SelectDialogTreeData): @@ -172,7 +172,7 @@ class SelectCardsetByTypeData(SelectDialogTreeData): self.no_contents = [SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ] # - items = CSI.TYPE.items() + items = list(CSI.TYPE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -183,9 +183,9 @@ class SelectCardsetByTypeData(SelectDialogTreeData): select_by_type = SelectCardsetNode( None, _("by Type"), tuple(nodes), expanded=1) # - self.rootnodes = filter(None, ( + self.rootnodes = [_f for _f in ( select_by_type, - )) + ) if _f] # ************************************************************************ diff --git a/pysollib/tile/selectgame.py b/pysollib/tile/selectgame.py index d2c92398..40366067 100644 --- a/pysollib/tile/selectgame.py +++ b/pysollib/tile/selectgame.py @@ -24,8 +24,8 @@ # imports import os -import ttk -from UserList import UserList +from . import ttk +from six.moves import UserList # PySol imports from pysollib.mygettext import _ @@ -36,9 +36,9 @@ from pysollib.resource import CSI # Toolkit imports from pysollib.ui.tktile.tkutil import unbind_destroy -from tkwidget import MfxDialog, MfxScrolledCanvas -from selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode -from selecttree import SelectDialogTreeData, SelectDialogTreeCanvas +from .tkwidget import MfxDialog, MfxScrolledCanvas +from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode +from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas # ************************************************************************ @@ -80,7 +80,8 @@ class SelectGameNode(SelectDialogTreeNode): class SelectGameData(SelectDialogTreeData): def __init__(self, app): SelectDialogTreeData.__init__(self) - self.all_games_gi = map(app.gdb.get, app.gdb.getGamesIdSortedByName()) + self.all_games_gi = list(map( + app.gdb.get, app.gdb.getGamesIdSortedByName())) self.no_games = [SelectGameLeaf(None, None, _("(no games)"), None), ] # s_by_type = s_oriental = s_special = s_original = s_contrib = \ @@ -94,7 +95,8 @@ class SelectGameData(SelectDialogTreeData): ): gg = [] for name, select_func in data: - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue gg.append(SelectGameNode(None, _(name), select_func)) g.append(gg) @@ -103,7 +105,7 @@ class SelectGameData(SelectDialogTreeData): return gi.si.game_type == GI.GT_MAHJONGG gg = None - if filter(select_mahjongg_game, self.all_games_gi): + if list(filter(select_mahjongg_game, self.all_games_gi)): gg = SelectGameNode(None, _("Mahjongg Games"), select_mahjongg_game) g.append(gg) @@ -128,7 +130,8 @@ class SelectGameData(SelectDialogTreeData): for name, games in GI.GAMES_BY_COMPATIBILITY: def select_func(gi, games=games): return gi.id in games - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: @@ -139,7 +142,8 @@ class SelectGameData(SelectDialogTreeData): for name, games in GI.GAMES_BY_PYSOL_VERSION: def select_func(gi, games=games): return gi.id in games - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue name = _("New games in v. ") + name gg.append(SelectGameNode(None, name, select_func)) @@ -150,7 +154,8 @@ class SelectGameData(SelectDialogTreeData): for name, games in GI.GAMES_BY_INVENTORS: def select_func(gi, games=games): return gi.id in games - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: @@ -160,7 +165,7 @@ class SelectGameData(SelectDialogTreeData): ul_alternate_names = UserList( list(app.gdb.getGamesTuplesSortedByAlternateName())) # - self.rootnodes = filter(None, ( + self.rootnodes = [_f for _f in ( SelectGameNode(None, _("All Games"), None, expanded=0), SelectGameNode(None, _("Alternate Names"), ul_alternate_names), SelectGameNode(None, _("Popular Games"), @@ -251,7 +256,7 @@ class SelectGameData(SelectDialogTreeData): )), s_original, s_contrib, - )) + ) if _f] # ************************************************************************ diff --git a/pysollib/tile/selecttile.py b/pysollib/tile/selecttile.py index 1b4ac550..7e163cb2 100644 --- a/pysollib/tile/selecttile.py +++ b/pysollib/tile/selecttile.py @@ -25,17 +25,17 @@ # imports import sys from six.moves import tkinter -import ttk -import tkColorChooser +from six.moves import tkinter_colorchooser +from . import ttk # PySol imports from pysollib.mygettext import _ from pysollib.mfxutil import KwStruct # Toolkit imports -from tkwidget import MfxDialog, MfxScrolledCanvas -from selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode -from selecttree import SelectDialogTreeData, SelectDialogTreeCanvas +from .tkwidget import MfxDialog, MfxScrolledCanvas +from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode +from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas if sys.version_info > (3,): @@ -175,9 +175,10 @@ class SelectTileDialogWithPreview(MfxDialog): self.tree.n_expansions = 1 # save xyview in any case if button == 10: # "Solid color..." try: - c = tkColorChooser.askcolor(master=self.top, - initialcolor=self.table_color, - title=_("Select table color")) + c = tkinter_colorchooser.askcolor( + master=self.top, + initialcolor=self.table_color, + title=_("Select table color")) except tkinter.TclError: pass else: diff --git a/pysollib/tile/selecttree.py b/pysollib/tile/selecttree.py index b1b62d1e..4cf2fdf2 100644 --- a/pysollib/tile/selecttree.py +++ b/pysollib/tile/selecttree.py @@ -24,7 +24,7 @@ __all__ = ['SelectDialogTreeData'] # Toolkit imports -from tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas +from .tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas from pysollib.ui.tktile.selecttree import BaseSelectDialogTreeLeaf, \ BaseSelectDialogTreeNode, SelectDialogTreeData, \