diff --git a/pysollib/customgame.py b/pysollib/customgame.py index cac707894..f72a1df99 100644 --- a/pysollib/customgame.py +++ b/pysollib/customgame.py @@ -70,8 +70,6 @@ UNLIMITED_MOVES from pysollib.wizardutil import WizardWidgets -import six - # ************************************************************************ # * # ************************************************************************ @@ -80,7 +78,7 @@ def get_settings(ss): s = {} for w in WizardWidgets: - if isinstance(w, six.string_types): + if isinstance(w, str): continue if w.var_name in ss: v = ss[w.var_name] diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index b41d7cc4d..633f257f5 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -26,6 +26,7 @@ import random import time import traceback +from io import BytesIO from pickle import Pickler, Unpickler, UnpicklingError import attr @@ -68,10 +69,6 @@ from pysollib.settings import VERSION, VERSION_TUPLE from pysollib.struct_new import NewStruct -import six -from six import BytesIO -from six.moves import range - if TOOLKIT == 'tk': from pysollib.ui.tktile.solverdialog import reset_solver_dialog else: @@ -104,7 +101,7 @@ def _updateStatus_process_key_val(tb, sb, k, v): # self.top.wm_title("%s - %s" # % (TITLE, self.getTitleName())) return - if isinstance(v, six.string_types): + if isinstance(v, str): if sb: sb.updateText(gamenumber=v) # self.top.wm_title("%s - %s %s" % (TITLE, @@ -146,7 +143,7 @@ def _updateStatus_process_key_val(tb, sb, k, v): if tb: tb.updateText(player=_("Player\n")) return - if isinstance(v, six.string_types): + if isinstance(v, str): if tb: # if self.app.opt.toolbar_size: if tb.getSize(): @@ -168,7 +165,7 @@ def _updateStatus_process_key_val(tb, sb, k, v): if v is None: if sb: sb.updateText(time='') - if isinstance(v, six.string_types): + if isinstance(v, str): if sb: sb.updateText(time=v) return @@ -1341,7 +1338,7 @@ def updateStatus(self, **kw): if self.preview: return tb, sb = self.app.toolbar, self.app.statusbar - for k, v in six.iteritems(kw): + for k, v in kw.items(): _updateStatus_process_key_val(tb, sb, k, v) def _unmapHandler(self, event): diff --git a/pysollib/games/mahjongg/mahjongg.py b/pysollib/games/mahjongg/mahjongg.py index 4a1fb784b..11d025a9a 100644 --- a/pysollib/games/mahjongg/mahjongg.py +++ b/pysollib/games/mahjongg/mahjongg.py @@ -40,8 +40,6 @@ OpenStack from pysollib.util import ANY_SUIT, NO_RANK -from six.moves import range - def factorial(x): if x <= 1: diff --git a/pysollib/games/mahjongg/shisensho.py b/pysollib/games/mahjongg/shisensho.py index a08da89cd..0d341383d 100644 --- a/pysollib/games/mahjongg/shisensho.py +++ b/pysollib/games/mahjongg/shisensho.py @@ -37,8 +37,6 @@ InitialDealTalonStack from pysollib.util import ANY_SUIT -from six.moves import range - class Shisen_Hint(AbstractHint): TOP_MATCHING = False diff --git a/pysollib/games/special/samegame.py b/pysollib/games/special/samegame.py index 34552e5f5..8500f291d 100644 --- a/pysollib/games/special/samegame.py +++ b/pysollib/games/special/samegame.py @@ -34,8 +34,6 @@ OpenStack from pysollib.util import ANY_SUIT -from six.moves import range - # ************************************************************************ # * Samegame diff --git a/pysollib/hint.py b/pysollib/hint.py index 2b0054d81..4810ce808 100644 --- a/pysollib/hint.py +++ b/pysollib/hint.py @@ -33,8 +33,6 @@ from pysollib.settings import DEBUG, FCS_COMMAND from pysollib.util import KING -import six - FCS_VERSION = None # ************************************************************************ @@ -819,7 +817,7 @@ def run_solver(self, command, board): if os.name != 'nt': kw['close_fds'] = True p = subprocess.Popen(command, **kw) - bytes_board = six.binary_type(board, 'utf-8') + bytes_board = bytes(board, 'utf-8') pout, perr = p.communicate(bytes_board) if p.returncode in (127, 1): # Linux and Windows return codes for "command not found" error @@ -1018,7 +1016,7 @@ def computeHints(self): FCS_VERSION = (5, 0, 0) else: pout, _ = self.run_solver(FCS_COMMAND + ' --version', '') - s = six.text_type(pout.read(), encoding='utf-8') + s = str(pout.read(), encoding='utf-8') m = re.search(r'version ([0-9]+)\.([0-9]+)\.([0-9]+)', s) if m: FCS_VERSION = (int(m.group(1)), int(m.group(2)), @@ -1082,7 +1080,7 @@ def computeHints(self): states = 0 for sbytes in pout: - s = six.text_type(sbytes, encoding='utf-8') + s = str(sbytes, encoding='utf-8') if DEBUG >= 5: print(s) @@ -1127,7 +1125,7 @@ def computeHints(self): self.solver_state = 'unsolved' else: for sbytes in pout: - s = six.text_type(sbytes, encoding='utf-8') + s = str(sbytes, encoding='utf-8') if DEBUG: print(s) if self._determineIfSolverState(s): @@ -1356,7 +1354,7 @@ def computeHints(self): pout, perr = self.run_solver(command, board) for sbytes in pout: - s = six.text_type(sbytes, encoding='utf-8') + s = str(sbytes, encoding='utf-8') if DEBUG >= 5: print(s) @@ -1390,7 +1388,7 @@ def computeHints(self): else: self.solver_state = result.lower() for sbytes in pout: - s = six.text_type(sbytes, encoding='utf-8') + s = str(sbytes, encoding='utf-8') if DEBUG: print(s) diff --git a/pysollib/kivy/selectgame.py b/pysollib/kivy/selectgame.py index 4b84ccdf0..99ca74b97 100644 --- a/pysollib/kivy/selectgame.py +++ b/pysollib/kivy/selectgame.py @@ -21,6 +21,8 @@ # # ---------------------------------------------------------------------------# +from collections import UserList + from kivy.clock import Clock from pysollib.gamedb import GI @@ -33,8 +35,6 @@ from pysollib.kivy.selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode from pysollib.mygettext import _ -from six.moves import UserList - # ************************************************************************ # * Nodes diff --git a/pysollib/mfxutil.py b/pysollib/mfxutil.py index d980204ee..13044e7cb 100644 --- a/pysollib/mfxutil.py +++ b/pysollib/mfxutil.py @@ -31,9 +31,6 @@ from pysollib.settings import PACKAGE, TOOLKIT -import six -from six import print_ - Image = ImageTk = ImageOps = ImageDraw = None if TOOLKIT == 'tk': try: # PIL @@ -125,9 +122,9 @@ def print_err(s, level=1): elif level == 2: ss = PACKAGE+': DEBUG WARNING:' try: - print_(ss, s, file=sys.stderr) + print(ss, s, file=sys.stderr) except Exception: - print_(ss, s.encode(locale.getpreferredencoding()), file=sys.stderr) + print(ss, s.encode(locale.getpreferredencoding()), file=sys.stderr) sys.stderr.flush() @@ -184,7 +181,7 @@ def getprefdir(package): def win32_getusername(): user = os.environ.get('USERNAME', '').strip() try: - user = six.text_type(user, locale.getpreferredencoding()) + user = str(user, locale.getpreferredencoding()) except Exception: user = '' return user diff --git a/pysollib/mygettext.py b/pysollib/mygettext.py index 1855645e3..9d24ceedb 100644 --- a/pysollib/mygettext.py +++ b/pysollib/mygettext.py @@ -1,10 +1,8 @@ import gettext import sys -import six - -class myLocalGettext(object): +class myLocalGettext: def __init__(self, lang): self.language = lang @@ -19,8 +17,8 @@ def translation(self): return t def maketext(self, msg): - if not isinstance(msg, six.text_type): - return six.text_type(msg, 'utf-8') + if not isinstance(msg, str): + return str(msg, 'utf-8') return msg def ungettext(self, msgid1, msgid2, n): diff --git a/pysollib/options.py b/pysollib/options.py index da6c94ee3..7f43c1f39 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -35,9 +35,6 @@ from pysollib.pysoltk import STATUSBAR_ITEMS, TOOLBAR_BUTTONS, TOOLKIT from pysollib.resource import CSI - -import six - import validate # ************************************************************************ @@ -663,7 +660,7 @@ def save(self, filename): val = getattr(self, key) if isinstance(val, str): if sys.version_info < (3,): - val = six.text_type(val, 'utf-8') + val = str(val, 'utf-8') config['general'][key] = val config['general']['recent_gameid'] = self.recent_gameid diff --git a/pysollib/pysolgtk/statusbar.py b/pysollib/pysolgtk/statusbar.py index 5ac50a494..47312c3ad 100644 --- a/pysollib/pysolgtk/statusbar.py +++ b/pysollib/pysolgtk/statusbar.py @@ -25,8 +25,6 @@ from pysollib.mygettext import _ -import six - class BasicStatusbar: def __init__(self, top, row, column, columnspan): @@ -60,7 +58,7 @@ def updateText(self, **kw): for k, v in kw.items(): label = getattr(self, k + "_label") label.pop(0) - label.push(0, six.text_type(v)) + label.push(0, str(v)) def config(self, name, show): # FIXME @@ -70,7 +68,7 @@ def configLabel(self, name, **kw): label = getattr(self, name + "_label") # FIXME kw['fg'] label.pop(0) - label.push(0, six.text_type(kw['text'])) + label.push(0, str(kw['text'])) def show(self, show=True, resize=False): if show: diff --git a/pysollib/pysolgtk/tkhtml.py b/pysollib/pysolgtk/tkhtml.py index f5d2e5d6d..aa182a1ab 100644 --- a/pysollib/pysolgtk/tkhtml.py +++ b/pysollib/pysolgtk/tkhtml.py @@ -38,8 +38,6 @@ from pysollib.mygettext import _ from pysollib.settings import TITLE -import six - from tkwidget import MfxMessageDialog if __name__ == '__main__': @@ -71,7 +69,7 @@ def __init__(self, text, viewer, app): self.indent = '' def write(self, data): - data = six.text_type(data) + data = str(data) self.text.insert(self.text.get_end_iter(), data, len(data)) def anchor_bgn(self, href, name, type): diff --git a/pysollib/resource.py b/pysollib/resource.py index 33176484f..0861f5913 100644 --- a/pysollib/resource.py +++ b/pysollib/resource.py @@ -29,8 +29,6 @@ from pysollib.mygettext import _ from pysollib.settings import DEBUG -import six - # ************************************************************************ # * Abstract # ************************************************************************ @@ -477,7 +475,7 @@ def getPreviewCardNames(self): def updateCardback(self, backname=None, backindex=None): # update default back - if isinstance(backname, six.string_types): + if isinstance(backname, str): if backname in self.backnames: backindex = self.backnames.index(backname) if isinstance(backindex, int): diff --git a/pysollib/stats.py b/pysollib/stats.py index 43ae131d6..0ee9f6946 100644 --- a/pysollib/stats.py +++ b/pysollib/stats.py @@ -27,8 +27,6 @@ from pysollib.mfxutil import format_time from pysollib.mygettext import _ -from six.moves import range - # ************************************************************************ # * # ************************************************************************ diff --git a/pysollib/tile/selectgame.py b/pysollib/tile/selectgame.py index f2a7cfd17..f979b7063 100644 --- a/pysollib/tile/selectgame.py +++ b/pysollib/tile/selectgame.py @@ -22,6 +22,7 @@ # --------------------------------------------------------------------------- import os +from collections import UserList from pysollib.gamedb import GI from pysollib.mfxutil import KwStruct, Struct, destruct @@ -31,7 +32,6 @@ from pysollib.ui.tktile.selecttree import SelectDialogTreeData from pysollib.ui.tktile.tkutil import bind, unbind_destroy -from six.moves import UserList from six.moves import tkinter from six.moves import tkinter_ttk as ttk diff --git a/pysollib/tile/selecttile.py b/pysollib/tile/selecttile.py index 3536dd294..c7ad0bb45 100644 --- a/pysollib/tile/selecttile.py +++ b/pysollib/tile/selecttile.py @@ -29,7 +29,6 @@ from pysollib.ui.tktile.selecttree import SelectDialogTreeData from pysollib.ui.tktile.tkutil import bind -import six from six.moves import tkinter from six.moves import tkinter_colorchooser from six.moves import tkinter_ttk as ttk @@ -276,7 +275,7 @@ def initKw(self, kw): def mDone(self, button): if button == 0: # "OK" or double click - if isinstance(self.tree.selection_key, six.string_types): + if isinstance(self.tree.selection_key, str): self.key = str(self.tree.selection_key) else: self.key = self.tree.selection_key @@ -378,7 +377,7 @@ def updatePreview(self, key, scaling=-1): canvas.deleteAllItems() self.preview_scaling = scaling - if isinstance(key, six.string_types): + if isinstance(key, str): if USE_PIL: self.textScale['state'] = 'disabled' # solid color diff --git a/pysollib/tile/statusbar.py b/pysollib/tile/statusbar.py index b93b66c08..5cc03161f 100644 --- a/pysollib/tile/statusbar.py +++ b/pysollib/tile/statusbar.py @@ -27,7 +27,6 @@ from pysollib.mygettext import _ -import six from six.moves import tkinter from six.moves import tkinter_ttk as ttk @@ -97,7 +96,7 @@ def _createSizegrip(self): def updateText(self, **kw): for k, v in kw.items(): label = getattr(self, k + '_label') - text = six.text_type(v) + text = str(v) width = label['width'] if width and len(text) > width: label['width'] = len(text) diff --git a/pysollib/tile/tkwidget.py b/pysollib/tile/tkwidget.py index 2e14d5feb..c0af8d00e 100644 --- a/pysollib/tile/tkwidget.py +++ b/pysollib/tile/tkwidget.py @@ -34,8 +34,6 @@ from pysollib.ui.tktile.tkutil import bind, unbind_destroy from pysollib.ui.tktile.tkutil import makeToplevel, setTransient -import six -from six import PY2 from six.moves import tkinter from six.moves import tkinter_font from six.moves import tkinter_ttk as ttk @@ -121,9 +119,9 @@ def altKeyEvent(self, event): key = event.char try: if os.name == 'nt': - key = six.text_type(key, locale.getpreferredencoding()) + key = str(key, locale.getpreferredencoding()) else: - key = six.text_type(key, 'utf-8') + key = str(key, 'utf-8') except Exception: pass else: @@ -289,8 +287,6 @@ def __init__(self, parent, ex, title="Error", **kw): (ex.errno, ex.strerror, repr(ex.filename)) else: t = str(ex) - if PY2: - t = six.text_type(t, errors='replace') kw.text = text + t MfxMessageDialog.__init__(self, parent, title, **kw.getKw()) diff --git a/pysollib/tile/wizarddialog.py b/pysollib/tile/wizarddialog.py index a33f061f5..8c28e74fa 100644 --- a/pysollib/tile/wizarddialog.py +++ b/pysollib/tile/wizarddialog.py @@ -26,7 +26,6 @@ from pysollib.wizardpresets import presets from pysollib.wizardutil import WizardWidgets -import six from six.moves import tkinter from six.moves import tkinter_ttk as ttk @@ -49,7 +48,7 @@ def __init__(self, parent, title, app, **kw): notebook.pack(expand=True, fill='both') for w in WizardWidgets: - if isinstance(w, six.string_types): + if isinstance(w, str): frame = ttk.Frame(notebook) notebook.add(frame, text=w, sticky='nsew', padding=5) frame.columnconfigure(1, weight=1) @@ -128,7 +127,7 @@ def presetSelected(self, e, w): n = w.translation_map[n] p = presets[n] for w in WizardWidgets: - if isinstance(w, six.string_types): + if isinstance(w, str): continue if w.var_name in p: v = p[w.var_name] diff --git a/pysollib/tk/selectgame.py b/pysollib/tk/selectgame.py index 75fd009b5..cb9207785 100644 --- a/pysollib/tk/selectgame.py +++ b/pysollib/tk/selectgame.py @@ -22,6 +22,7 @@ # --------------------------------------------------------------------------- import os +from collections import UserList from pysollib.gamedb import GI from pysollib.mfxutil import KwStruct, Struct, destruct @@ -31,7 +32,6 @@ from pysollib.ui.tktile.selecttree import SelectDialogTreeData from pysollib.ui.tktile.tkutil import unbind_destroy -from six.moves import UserList from six.moves import tkinter from .selecttree import SelectDialogTreeCanvas diff --git a/pysollib/tk/selecttile.py b/pysollib/tk/selecttile.py index 1365a9093..b586df4e5 100644 --- a/pysollib/tk/selecttile.py +++ b/pysollib/tk/selecttile.py @@ -26,7 +26,6 @@ from pysollib.mygettext import _ from pysollib.ui.tktile.selecttree import SelectDialogTreeData -import six from six.moves import tkinter, tkinter_colorchooser from .selecttree import SelectDialogTreeCanvas @@ -172,10 +171,7 @@ def initKw(self, kw): def mDone(self, button): if button == 0: # "OK" or double click - if isinstance(self.tree.selection_key, six.string_types): - self.key = str(self.tree.selection_key) - else: - self.key = self.tree.selection_key + self.key = self.tree.selection_key self.tree.n_expansions = 1 # save xyview in any case if button == 1: # "Solid color..." try: @@ -201,7 +197,7 @@ def updatePreview(self, key): return canvas = self.preview.canvas canvas.deleteAllItems() - if isinstance(key, six.string_types): + if isinstance(key, str): # solid color canvas.config(bg=key) canvas.setTile(None) diff --git a/pysollib/tk/statusbar.py b/pysollib/tk/statusbar.py index 6d9b6ea0a..89cef5fbd 100644 --- a/pysollib/tk/statusbar.py +++ b/pysollib/tk/statusbar.py @@ -27,7 +27,6 @@ from pysollib.mygettext import _ from pysollib.settings import WIN_SYSTEM -import six from six.moves import tkinter from .tkwidget import MfxTooltip @@ -96,7 +95,7 @@ def _createLabel(self, name, expand=False, width=0, tooltip=None): def updateText(self, **kw): for k, v in kw.items(): label = getattr(self, k + '_label') - text = six.text_type(v) + text = str(v) width = label['width'] if width and len(text) > width: label['width'] = len(text) diff --git a/pysollib/tk/tkwidget.py b/pysollib/tk/tkwidget.py index c8cb34ee0..228db91fa 100644 --- a/pysollib/tk/tkwidget.py +++ b/pysollib/tk/tkwidget.py @@ -32,7 +32,6 @@ from pysollib.ui.tktile.tkutil import bind, unbind_destroy from pysollib.ui.tktile.tkutil import makeToplevel, setTransient -import six from six.moves import tkinter from six.moves import tkinter_font @@ -130,7 +129,7 @@ def mDone(self, button): def altKeyEvent(self, event): key = event.char - key = six.text_type(key, 'utf-8') + key = str(key, 'utf-8') key = key.lower() button = self.accel_keys.get(key) if button is not None: @@ -285,7 +284,7 @@ def __init__(self, parent, ex, title="Error", **kw): (ex.errno, ex.strerror, repr(ex.filename)) else: t = str(ex) - kw.text = text + six.text_type(t, errors='replace') + kw.text = text + str(t, errors='replace') MfxMessageDialog.__init__(self, parent, title, **kw.getKw()) diff --git a/pysollib/tk/wizarddialog.py b/pysollib/tk/wizarddialog.py index 24baa8556..891caeb3f 100644 --- a/pysollib/tk/wizarddialog.py +++ b/pysollib/tk/wizarddialog.py @@ -26,7 +26,6 @@ from pysollib.wizardpresets import presets from pysollib.wizardutil import WizardWidgets -import six from six.moves import tkinter from .tabpage import TabPageSet @@ -48,7 +47,7 @@ def __init__(self, parent, title, app, **kw): notebook.pack(expand=True, fill='both') for w in WizardWidgets: - if isinstance(w, six.string_types): + if isinstance(w, str): notebook.AddPage(w) frame = tkinter.Frame(notebook.pages[w]['page']) frame.pack(expand=True, fill='both', padx=2, pady=4) @@ -117,7 +116,7 @@ def presetSelected(self, v, w): n = w.translation_map[v] p = presets[n] for w in WizardWidgets: - if isinstance(w, six.string_types): + if isinstance(w, str): continue if w.var_name in p: v = p[w.var_name] diff --git a/pysollib/util.py b/pysollib/util.py index 048a43fec..738415449 100644 --- a/pysollib/util.py +++ b/pysollib/util.py @@ -37,8 +37,6 @@ def __init__(self): from pysollib.mygettext import _ from pysollib.settings import DATA_DIRS, TOOLKIT -import six - # ************************************************************************ # * constants # ************************************************************************ @@ -152,8 +150,8 @@ def __init__(self, argv0, filenames, path=[]): def __findFile(self, func, filename, subdirs=None, do_raise=1): if subdirs is None: subdirs = ("",) - elif isinstance(subdirs, six.string_types): - subdirs = (str(subdirs),) + elif isinstance(subdirs, str): + subdirs = (subdirs,) for dir in subdirs: f = os.path.join(self.dir, dir, filename) f = os.path.normpath(f) diff --git a/pysollib/wizardutil.py b/pysollib/wizardutil.py index 9d9ff7bde..a8de420ee 100644 --- a/pysollib/wizardutil.py +++ b/pysollib/wizardutil.py @@ -66,8 +66,6 @@ from pysollib.util import ACE, ANY_RANK, KING, NO_RANK, UNLIMITED_MOVES from pysollib.wizardpresets import presets -import six - # ************************************************************************ # * # ************************************************************************ @@ -436,7 +434,7 @@ class MyCustomGame(CustomGame): ''') for w in WizardWidgets: - if isinstance(w, six.string_types): + if isinstance(w, str): continue v = w.variable.get() if w.widget in ('menu', 'preset'): @@ -455,7 +453,7 @@ class MyCustomGame(CustomGame): v = v.replace("\r", "\\r") v = v.replace("\t", "\\t") # See: https://github.com/shlomif/PySolFC/issues/177 - # if isinstance(v, six.text_type): + # if isinstance(v, str): # v = v.encode('utf-8') if not v: v = 'Invalid Game Name' @@ -481,7 +479,7 @@ def delete_game(game): def reset_wizard(game): for w in WizardWidgets: - if isinstance(w, six.string_types): + if isinstance(w, str): continue if game is None: # set to default diff --git a/scripts/all_games.py b/scripts/all_games.py index 94cb8dd3b..2f1ef0088 100755 --- a/scripts/all_games.py +++ b/scripts/all_games.py @@ -2,6 +2,7 @@ # -*- mode: python; coding: koi8-r; -*- # +import builtins import os import sys import time @@ -16,7 +17,6 @@ from pysollib.mygettext import fix_gettext from pysollib.resource import CSI -from six.moves import builtins os.environ['LANG'] = 'C' builtins.__dict__['_'] = lambda x: x builtins.__dict__['n_'] = lambda x: x