diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e012e982 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +tests/individually-importing/*.py +build/* +data/cardsets/* +data/html/* +dist/* +docs/all_games.html +html-src/html/* +locale/* +po/pl.po +po/ru.po +*.pyc diff --git a/Makefile b/Makefile index 926e06cd..d10fe22d 100644 --- a/Makefile +++ b/Makefile @@ -58,3 +58,8 @@ mo: done cp -f locale/pl/LC_MESSAGES/pysol.mo locale/pl_PL/LC_MESSAGES/pysol.mo cp -f locale/it/LC_MESSAGES/pysol.mo locale/it_IT/LC_MESSAGES/pysol.mo + +test: + @rm -f tests/individually-importing/*.py # To avoid stray files + python scripts/gen_individual_importing_tests.py + runprove tests/individually-importing/*.py diff --git a/html-src/rules/daddylonglegs.html b/html-src/rules/daddylonglegs.html new file mode 100644 index 00000000..5a39b6a9 --- /dev/null +++ b/html-src/rules/daddylonglegs.html @@ -0,0 +1,14 @@ +

Daddy Longlegs

+

Spider type. 1 deck. No redeal.

+

Object

+

Group all the cards into four sets of 13 cards by suit in ascending sequence from Ace to King.

+

Rules

+

Cards are dealt four at a time, one card into each of four piles. A card can be moved onto the end of another pile, if it is the same suit and follows in sequence. The rest of the pile moves with the card. Only an Ace (with the rest of its pile) can move to an empty space.

+

At any time, you can deal more cards by clicking on the talon. One card will be added to each of the playing piles.

+

History

+

I created Daddy Longlegs in the early 1980's to amuse myself with a different solitaire variant. Over the years, I have implemented this game many times under the name of "Deal Four" as an exercise when learning new programming languages.

+

I learned of pysol in 2006 and almost immediately realized that it is a perfect platform for Daddy Longlegs. Thank you, Markus Oberhumer!

+

Author

+

Jim Sizelove

+

sizelji@comcast.net

+

March 8, 2007

diff --git a/pysollib/acard.py b/pysollib/acard.py index 8ac035b8..89673a33 100644 --- a/pysollib/acard.py +++ b/pysollib/acard.py @@ -26,7 +26,7 @@ from random import randint # PySol imports -from mfxutil import SubclassResponsibility +from pysollib.mfxutil import SubclassResponsibility # ************************************************************************ # * diff --git a/pysollib/actions.py b/pysollib/actions.py index d8ac03b9..0f0421e8 100644 --- a/pysollib/actions.py +++ b/pysollib/actions.py @@ -26,17 +26,17 @@ import os, locale # PySol imports -from mfxutil import SubclassResponsibility -from mfxutil import Struct, openURL -from mfxutil import print_err -from pysolrandom import constructRandom -from settings import TITLE, PACKAGE_URL -from settings import TOP_TITLE -from settings import DEBUG -from gamedb import GI +from pysollib.mfxutil import SubclassResponsibility +from pysollib.mfxutil import Struct, openURL +from pysollib.mfxutil import print_err +from pysollib.pysolrandom import constructRandom +from pysollib.settings import TITLE, PACKAGE_URL +from pysollib.settings import TOP_TITLE +from pysollib.settings import DEBUG +from pysollib.gamedb import GI # stats imports -from stats import FileStatsFormatter +from pysollib.stats import FileStatsFormatter from pysollib.pysoltk import SingleGame_StatsDialog, AllGames_StatsDialog from pysollib.pysoltk import FullLog_StatsDialog, SessionLog_StatsDialog from pysollib.pysoltk import Status_StatsDialog, Top_StatsDialog @@ -44,6 +44,7 @@ from pysollib.pysoltk import ProgressionDialog from pysollib.pysoltk import GameInfoDialog # toolkit imports +from pysollib.mygettext import _, n_ from pysollib.pysoltk import MfxMessageDialog, MfxSimpleEntry from pysollib.pysoltk import MfxExceptionDialog from pysollib.pysoltk import PlayerOptionsDialog @@ -54,7 +55,7 @@ from pysollib.pysoltk import EditTextDialog from pysollib.pysoltk import create_find_card_dialog from pysollib.pysoltk import create_solver_dialog from pysollib.pysoltk import PysolMenubarTk, PysolToolbarTk -from help import help_about, help_html +from pysollib.help import help_about, help_html # ************************************************************************ diff --git a/pysollib/app.py b/pysollib/app.py index 3ed27699..afb5a2f8 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -27,26 +27,27 @@ import os, re import traceback # PySol imports -from mfxutil import destruct, Struct -from mfxutil import pickle, unpickle, UnpicklingError -from mfxutil import getusername, getprefdir -from mfxutil import latin1_to_ascii, print_err -from mfxutil import USE_PIL -from util import CARDSET, IMAGE_EXTENSIONS -from settings import PACKAGE, VERSION_TUPLE, WIN_SYSTEM -from resource import CSI, CardsetConfig, Cardset, CardsetManager -from resource import Tile, TileManager -from resource import Sample, SampleManager -from resource import Music, MusicManager +from pysollib.mfxutil import destruct, Struct +from pysollib.mfxutil import pickle, unpickle, UnpicklingError +from pysollib.mfxutil import getusername, getprefdir +from pysollib.mfxutil import latin1_to_ascii, print_err +from pysollib.mfxutil import USE_PIL +from pysollib.util import CARDSET, IMAGE_EXTENSIONS +from pysollib.settings import PACKAGE, VERSION_TUPLE, WIN_SYSTEM +from pysollib.resource import CSI, CardsetConfig, Cardset, CardsetManager +from pysollib.resource import Tile, TileManager +from pysollib.resource import Sample, SampleManager +from pysollib.resource import Music, MusicManager from pysollib.images import Images, SubsampledImages -from pysolrandom import PysolRandom -from gamedb import GI, GAME_DB, loadGame -from options import Options -from settings import TOP_SIZE, TOOLKIT -from settings import DEBUG -from winsystems import TkSettings +from pysollib.pysolrandom import PysolRandom +from pysollib.gamedb import GI, GAME_DB, loadGame +from pysollib.options import Options +from pysollib.settings import TOP_SIZE, TOOLKIT +from pysollib.settings import DEBUG +from pysollib.winsystems import TkSettings # Toolkit imports +from pysollib.mygettext import _, n_ from pysollib.pysoltk import wm_withdraw, loadImage from pysollib.pysoltk import MfxDialog, MfxMessageDialog, MfxExceptionDialog from pysollib.pysoltk import TclError, MfxScrolledCanvas @@ -58,10 +59,9 @@ from pysollib.pysoltk import HTMLViewer from pysollib.pysoltk import destroy_find_card_dialog from pysollib.pysoltk import destroy_solver_dialog -from actions import PysolMenubar -from actions import PysolToolbar -from help import help_about, destroy_help_html - +from pysollib.actions import PysolMenubar +from pysollib.actions import PysolToolbar +from pysollib.help import help_about, destroy_help_html # ************************************************************************ # * Statistics @@ -516,7 +516,7 @@ class Application: self.nextgame.id, self.nextgame.random = 0, None try: self.runGame(id, random) - except: + except Exception: # try Klondike if current game fails if id == 2: raise # internal error? diff --git a/pysollib/customgame.py b/pysollib/customgame.py index 9f49f581..f9f61e1f 100644 --- a/pysollib/customgame.py +++ b/pysollib/customgame.py @@ -21,15 +21,14 @@ ## ##---------------------------------------------------------------------------## -from gamedb import registerGame, GameInfo, GI -from util import * -from stack import * -from game import Game -from layout import Layout -from hint import AbstractHint, DefaultHint, CautiousDefaultHint, Yukon_Hint - -from wizardutil import WizardWidgets +from pysollib.gamedb import registerGame, GameInfo, GI +from pysollib.util import * +from pysollib.stack import * +from pysollib.game import Game +from pysollib.layout import Layout +from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint, Yukon_Hint +from pysollib.wizardutil import WizardWidgets # ************************************************************************ # * diff --git a/pysollib/game.py b/pysollib/game.py index ce653077..bd0e57a3 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -26,20 +26,23 @@ import time import math import traceback + +from pysollib.mygettext import _, n_ + from gettext import ungettext from cStringIO import StringIO # PySol imports -from mfxutil import Pickler, Unpickler, UnpicklingError -from mfxutil import Image, ImageTk, USE_PIL -from mfxutil import destruct, Struct, SubclassResponsibility -from mfxutil import uclock, usleep -from mfxutil import format_time, print_err -from settings import PACKAGE, TITLE, TOOLKIT, TOP_TITLE -from settings import VERSION, VERSION_TUPLE -from settings import DEBUG -from gamedb import GI -from pysolrandom import PysolRandom, LCRandom31 +from pysollib.mfxutil import Pickler, Unpickler, UnpicklingError +from pysollib.mfxutil import Image, ImageTk, USE_PIL +from pysollib.mfxutil import destruct, Struct, SubclassResponsibility +from pysollib.mfxutil import uclock, usleep +from pysollib.mfxutil import format_time, print_err +from pysollib.settings import PACKAGE, TITLE, TOOLKIT, TOP_TITLE +from pysollib.settings import VERSION, VERSION_TUPLE +from pysollib.settings import DEBUG +from pysollib.gamedb import GI +from pysollib.pysolrandom import PysolRandom, LCRandom31 from pysollib.pysoltk import EVENT_HANDLED, EVENT_PROPAGATE from pysollib.pysoltk import CURSOR_WATCH from pysollib.pysoltk import bind, wm_map @@ -48,13 +51,13 @@ from pysollib.pysoltk import MfxMessageDialog, MfxExceptionDialog from pysollib.pysoltk import MfxCanvasText, MfxCanvasLine, MfxCanvasRectangle from pysollib.pysoltk import Card from pysollib.pysoltk import reset_solver_dialog -from move import AMoveMove, AFlipMove, AFlipAndMoveMove -from move import ASingleFlipMove, ATurnStackMove -from move import ANextRoundMove, ASaveSeedMove, AShuffleStackMove -from move import AUpdateStackMove, AFlipAllMove, ASaveStateMove -from move import ASingleCardMove -from hint import DefaultHint -from help import help_about +from pysollib.move import AMoveMove, AFlipMove, AFlipAndMoveMove +from pysollib.move import ASingleFlipMove, ATurnStackMove +from pysollib.move import ANextRoundMove, ASaveSeedMove, AShuffleStackMove +from pysollib.move import AUpdateStackMove, AFlipAllMove, ASaveStateMove +from pysollib.move import ASingleCardMove +from pysollib.hint import DefaultHint +from pysollib.help import help_about PLAY_TIME_TIMEOUT = 200 @@ -254,7 +257,7 @@ class Game: '%s: %s %s' % (class_name, ncards, self.gameinfo.ncards), 2) if self.s.rows: - from stack import AC_RowStack, UD_AC_RowStack, \ + from pysollib.stack import AC_RowStack, UD_AC_RowStack, \ SS_RowStack, UD_SS_RowStack, \ RK_RowStack, UD_RK_RowStack, \ Spider_AC_RowStack, Spider_SS_RowStack @@ -3303,8 +3306,8 @@ in the current implementation.''') % version) # def showStackDesc(self): - from pysoltk import StackDesc - from stack import InitialDealTalonStack + from pysollib.pysoltk import StackDesc + from pysollib.stack import InitialDealTalonStack sd_list = [] for s in self.allstacks: sd = (s.__class__.__name__, s.cap.base_rank, s.cap.dir) diff --git a/pysollib/gamedb.py b/pysollib/gamedb.py index 94e3d404..f2f6c1e3 100644 --- a/pysollib/gamedb.py +++ b/pysollib/gamedb.py @@ -26,10 +26,11 @@ import imp # PySol imports -from mfxutil import Struct, print_err -from resource import CSI -import settings +from pysollib.mfxutil import Struct, print_err +from pysollib.resource import CSI +import pysollib.settings +from pysollib.mygettext import _, n_ # ************************************************************************ # * constants @@ -420,18 +421,18 @@ class GameInfo(Struct): game_type = game_type & 1023 name = to_unicode(name) en_name = name # for app.getGameRulesFilename - if settings.TRANSLATE_GAME_NAMES: + if pysollib.settings.TRANSLATE_GAME_NAMES: name = _(name) if not short_name: short_name = name else: short_name = to_unicode(short_name) - if settings.TRANSLATE_GAME_NAMES: + if pysollib.settings.TRANSLATE_GAME_NAMES: short_name = _(short_name) if isinstance(altnames, basestring): altnames = (altnames,) altnames = [to_unicode(n) for n in altnames] - if settings.TRANSLATE_GAME_NAMES: + if pysollib.settings.TRANSLATE_GAME_NAMES: altnames = [_(n) for n in altnames] # if not (1 <= category <= 9): @@ -545,7 +546,7 @@ class GameManager: ##print gi.id, gi.short_name.encode('utf-8') if not isinstance(gi, GameInfo): raise GameInfoException("wrong GameInfo class") - if self.check_game and settings.CHECK_GAMES: + if self.check_game and pysollib.settings.CHECK_GAMES: self._check_game(gi) ##if 0 and gi.si.game_flags & GI.GT_XORIGINAL: ## return diff --git a/pysollib/games/__init__.py b/pysollib/games/__init__.py index ce23f9fe..2c9a629c 100644 --- a/pysollib/games/__init__.py +++ b/pysollib/games/__init__.py @@ -35,6 +35,7 @@ import camelot import canfield import capricieuse import curdsandwhey +import daddylonglegs import dieboesesieben import diplomat import doublets diff --git a/pysollib/games/auldlangsyne.py b/pysollib/games/auldlangsyne.py index 208d8e85..fca8653f 100644 --- a/pysollib/games/auldlangsyne.py +++ b/pysollib/games/auldlangsyne.py @@ -26,6 +26,7 @@ __all__ = [] # imports # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/braid.py b/pysollib/games/braid.py index dad0d7c1..35bad1db 100644 --- a/pysollib/games/braid.py +++ b/pysollib/games/braid.py @@ -27,6 +27,7 @@ __all__ = [] import sys, math # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/calculation.py b/pysollib/games/calculation.py index a39c3b41..24954bb8 100644 --- a/pysollib/games/calculation.py +++ b/pysollib/games/calculation.py @@ -1,32 +1,3 @@ -#!/usr/bin/env python -# -*- mode: python; coding: utf-8; -*- -##---------------------------------------------------------------------------## -## -## Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer -## Copyright (C) 2003 Mt. Hood Playing Card Co. -## Copyright (C) 2005-2009 Skomoroh -## -## This program is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -## -##---------------------------------------------------------------------------## - -__all__ = [] - -# imports -import sys - -# PySol imports from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/camelot.py b/pysollib/games/camelot.py index 851aab70..cd3906ce 100644 --- a/pysollib/games/camelot.py +++ b/pysollib/games/camelot.py @@ -26,6 +26,7 @@ __all__ = [] # imports # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/canfield.py b/pysollib/games/canfield.py index 05352ccf..589c111f 100644 --- a/pysollib/games/canfield.py +++ b/pysollib/games/canfield.py @@ -1,32 +1,3 @@ -#!/usr/bin/env python -# -*- mode: python; coding: utf-8; -*- -##---------------------------------------------------------------------------## -## -## Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer -## Copyright (C) 2003 Mt. Hood Playing Card Co. -## Copyright (C) 2005-2009 Skomoroh -## -## This program is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -## -##---------------------------------------------------------------------------## - -__all__ = [] - -# imports -import sys - -# PySol imports from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/curdsandwhey.py b/pysollib/games/curdsandwhey.py index ddf828d0..20173022 100644 --- a/pysollib/games/curdsandwhey.py +++ b/pysollib/games/curdsandwhey.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/daddylonglegs.py b/pysollib/games/daddylonglegs.py new file mode 100644 index 00000000..00bdf45b --- /dev/null +++ b/pysollib/games/daddylonglegs.py @@ -0,0 +1,57 @@ +## vim:ts=4:et:nowrap:fileencoding=utf-8 +## + +# imports +import sys + +# PySol imports +from pysollib.gamedb import registerGame, GameInfo, GI +from pysollib.util import * +from pysollib.stack import * +from pysollib.game import Game +from pysollib.layout import Layout + + +#*********************************************************************** +# Daddy Longlegs (by Jim Sizelove) +#*********************************************************************** + +class DaddyLonglegs(Game): + Talon_Class = DealRowTalonStack + RowStack_Class = StackWrapper(Yukon_SS_RowStack, dir=1, base_rank=ACE) + + def createGame(self, **layout): + # create layout + l, s = Layout(self), self.s + + # set window + self.setSize(l.XM + 6*l.XS, l.YM + 7*l.YS) + + # create stacks + x, y, = l.XM, l.YM + s.talon = self.Talon_Class(x, y, self) + l.createText(s.talon, "ss") + x = x + 3*l.XS/2 + for i in range(4): + s.rows.append(self.RowStack_Class(x, y, self)) + x = x + l.XS + + # define stack-groups + l.defaultStackGroups() + + def startGame(self): + self.s.talon.dealRow() + + def isGameWon(self): + if self.s.talon.cards: + return 0 + for row in self.s.rows: + if not isSameSuitSequence(row.cards, dir=1): + return 0 + return 1 + + +# register the game +registerGame(GameInfo(555001, DaddyLonglegs, "Daddy Longlegs", + GI.GT_SPIDER, 1, 0, GI.SL_MOSTLY_SKILL, + rules_filename="daddylonglegs.html")) diff --git a/pysollib/games/fan.py b/pysollib/games/fan.py index 680138c7..3a0110ea 100644 --- a/pysollib/games/fan.py +++ b/pysollib/games/fan.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/golf.py b/pysollib/games/golf.py index 5952f591..e793ab22 100644 --- a/pysollib/games/golf.py +++ b/pysollib/games/golf.py @@ -27,6 +27,7 @@ __all__ = [] import sys, types # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/klondike.py b/pysollib/games/klondike.py index bd0ce7b9..9b54cde6 100644 --- a/pysollib/games/klondike.py +++ b/pysollib/games/klondike.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault, Struct diff --git a/pysollib/games/larasgame.py b/pysollib/games/larasgame.py index 274dc215..34b0e134 100644 --- a/pysollib/games/larasgame.py +++ b/pysollib/games/larasgame.py @@ -26,6 +26,7 @@ __all__ = [] # imports # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/mahjongg/mahjongg.py b/pysollib/games/mahjongg/mahjongg.py index d1b36930..1a2ff010 100644 --- a/pysollib/games/mahjongg/mahjongg.py +++ b/pysollib/games/mahjongg/mahjongg.py @@ -30,6 +30,7 @@ import time from gettext import ungettext # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault, Struct, Image diff --git a/pysollib/games/mahjongg/shisensho.py b/pysollib/games/mahjongg/shisensho.py index 71804a32..85bad369 100644 --- a/pysollib/games/mahjongg/shisensho.py +++ b/pysollib/games/mahjongg/shisensho.py @@ -29,6 +29,7 @@ import sys from gettext import ungettext # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/matriarchy.py b/pysollib/games/matriarchy.py index 72d0baa3..91fb132c 100644 --- a/pysollib/games/matriarchy.py +++ b/pysollib/games/matriarchy.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/napoleon.py b/pysollib/games/napoleon.py index d2f9e071..541e693d 100644 --- a/pysollib/games/napoleon.py +++ b/pysollib/games/napoleon.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/numerica.py b/pysollib/games/numerica.py index c0818d98..1a495fd1 100644 --- a/pysollib/games/numerica.py +++ b/pysollib/games/numerica.py @@ -27,6 +27,7 @@ __all__ = [] import sys, time # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/osmosis.py b/pysollib/games/osmosis.py index 79b5972a..6ea7284f 100644 --- a/pysollib/games/osmosis.py +++ b/pysollib/games/osmosis.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/pileon.py b/pysollib/games/pileon.py index 7d030e2c..1cd28691 100644 --- a/pysollib/games/pileon.py +++ b/pysollib/games/pileon.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/royalcotillion.py b/pysollib/games/royalcotillion.py index 8f68c72e..d2d6f403 100644 --- a/pysollib/games/royalcotillion.py +++ b/pysollib/games/royalcotillion.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/special/memory.py b/pysollib/games/special/memory.py index b229392d..526b8239 100644 --- a/pysollib/games/special/memory.py +++ b/pysollib/games/special/memory.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/special/poker.py b/pysollib/games/special/poker.py index 08e11fed..8d248228 100644 --- a/pysollib/games/special/poker.py +++ b/pysollib/games/special/poker.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.stack import * diff --git a/pysollib/games/special/tarock.py b/pysollib/games/special/tarock.py index 43edd47e..3fd3b263 100644 --- a/pysollib/games/special/tarock.py +++ b/pysollib/games/special/tarock.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/spider.py b/pysollib/games/spider.py index 77e4a4ba..0aaf283e 100644 --- a/pysollib/games/spider.py +++ b/pysollib/games/spider.py @@ -26,6 +26,7 @@ __all__ = [] # imports # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/takeaway.py b/pysollib/games/takeaway.py index ec0e6058..db8e5ccb 100644 --- a/pysollib/games/takeaway.py +++ b/pysollib/games/takeaway.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/terrace.py b/pysollib/games/terrace.py index df4ce383..2f978cb3 100644 --- a/pysollib/games/terrace.py +++ b/pysollib/games/terrace.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/threepeaks.py b/pysollib/games/threepeaks.py index 020e6bad..bdd9c0b7 100644 --- a/pysollib/games/threepeaks.py +++ b/pysollib/games/threepeaks.py @@ -26,6 +26,7 @@ __all__ = [] # Imports # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/tournament.py b/pysollib/games/tournament.py index c474fe18..eada5869 100644 --- a/pysollib/games/tournament.py +++ b/pysollib/games/tournament.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/ultra/dashavatara.py b/pysollib/games/ultra/dashavatara.py index 976aab9f..2ffe54b6 100644 --- a/pysollib/games/ultra/dashavatara.py +++ b/pysollib/games/ultra/dashavatara.py @@ -26,7 +26,9 @@ __all__ = [] # Imports import sys, math, time + # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/ultra/hanafuda.py b/pysollib/games/ultra/hanafuda.py index 1d64d4e9..ade6c4c9 100644 --- a/pysollib/games/ultra/hanafuda.py +++ b/pysollib/games/ultra/hanafuda.py @@ -27,6 +27,7 @@ __all__ = [] import sys, math # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/ultra/hanafuda1.py b/pysollib/games/ultra/hanafuda1.py index 58b945b1..7638ed06 100644 --- a/pysollib/games/ultra/hanafuda1.py +++ b/pysollib/games/ultra/hanafuda1.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/ultra/hanafuda_common.py b/pysollib/games/ultra/hanafuda_common.py index b4b95416..a2a6c766 100644 --- a/pysollib/games/ultra/hanafuda_common.py +++ b/pysollib/games/ultra/hanafuda_common.py @@ -52,6 +52,7 @@ __all__ = [ import sys, math +from pysollib.mygettext import _, n_ from pysollib.util import * from pysollib.mfxutil import kwdefault from pysollib.stack import * diff --git a/pysollib/games/ultra/hexadeck.py b/pysollib/games/ultra/hexadeck.py index e635b3c3..1dede9c1 100644 --- a/pysollib/games/ultra/hexadeck.py +++ b/pysollib/games/ultra/hexadeck.py @@ -27,6 +27,7 @@ __all__ = [] import sys, math # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/ultra/mughal.py b/pysollib/games/ultra/mughal.py index 563f6292..b9c1ac5e 100644 --- a/pysollib/games/ultra/mughal.py +++ b/pysollib/games/ultra/mughal.py @@ -27,6 +27,7 @@ __all__ = [] import sys, math # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/games/yukon.py b/pysollib/games/yukon.py index a3d4bc15..c2dff463 100644 --- a/pysollib/games/yukon.py +++ b/pysollib/games/yukon.py @@ -27,6 +27,7 @@ __all__ = [] import sys # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.util import * from pysollib.mfxutil import kwdefault diff --git a/pysollib/help.py b/pysollib/help.py index 540721b2..97fd61a3 100644 --- a/pysollib/help.py +++ b/pysollib/help.py @@ -25,7 +25,8 @@ # imports # PySol imports -from settings import TITLE, PACKAGE_URL, TOOLKIT, VERSION +from pysollib.mygettext import _, n_ +from pysollib.settings import TITLE, PACKAGE_URL, TOOLKIT, VERSION from pysollib.pysoltk import make_help_toplevel from pysollib.pysoltk import MfxMessageDialog from pysollib.pysoltk import PysolAboutDialog diff --git a/pysollib/hint.py b/pysollib/hint.py index ba53daac..7b62ca9e 100644 --- a/pysollib/hint.py +++ b/pysollib/hint.py @@ -29,10 +29,9 @@ import subprocess import re # PySol imports -from settings import DEBUG, FCS_COMMAND -from mfxutil import destruct -from util import KING - +from pysollib.settings import DEBUG, FCS_COMMAND +from pysollib.mfxutil import destruct +from pysollib.util import KING # ************************************************************************ # * HintInterface is an abstract class that defines the public @@ -717,7 +716,6 @@ class FreeCellSolver_Hint: self.dialog = dialog self.game_type = game_type self.options = { - 'method': 'soft-dfs', 'max_iters': 10000, 'max_depth': 1000, 'progress': False, @@ -824,7 +822,6 @@ class FreeCellSolver_Hint: args += ['--load-config', self.options['preset']] args += ['--max-iters', self.options['max_iters'], '--max-depth', self.options['max_depth'], - '--method', self.options['method'], '--decks-num', game.gameinfo.decks, '--stacks-num', len(game.s.rows), '--freecells-num', len(game.s.reserves), diff --git a/pysollib/images.py b/pysollib/images.py index 622ac9bc..c4739cfa 100644 --- a/pysollib/images.py +++ b/pysollib/images.py @@ -34,7 +34,6 @@ from pysollib.mfxutil import Image, ImageTk, USE_PIL # Toolkit imports from pysollib.pysoltk import loadImage, copyImage, createImage, shadowImage, createBottom, resizeBottom - # ************************************************************************ # * Images # ************************************************************************ diff --git a/pysollib/init.py b/pysollib/init.py index 8fe362dd..fa0318cb 100644 --- a/pysollib/init.py +++ b/pysollib/init.py @@ -23,48 +23,17 @@ import sys, os, locale, subprocess import traceback -import gettext -import settings +from pysollib.mygettext import _, n_ +import gettext +import pysollib.settings # ************************************************************************ # * init # ************************************************************************ -def fix_gettext(): - def ugettext(message): - # unicoded gettext - if not isinstance(message, unicode): - message = unicode(message, 'utf-8') - domain = gettext._current_domain - try: - t = gettext.translation(domain, - gettext._localedirs.get(domain, None)) - except IOError: - return message - return t.ugettext(message) - gettext.ugettext = ugettext - def ungettext(msgid1, msgid2, n): - # unicoded ngettext - if not isinstance(msgid1, unicode): - msgid1 = unicode(msgid1, 'utf-8') - if not isinstance(msgid2, unicode): - msgid2 = unicode(msgid2, 'utf-8') - domain = gettext._current_domain - try: - t = gettext.translation(domain, - gettext._localedirs.get(domain, None)) - except IOError: - if n == 1: - return msgid1 - else: - return msgid2 - return t.ungettext(msgid1, msgid2, n) - gettext.ungettext = ungettext - def init(): - fix_gettext() if os.name == 'nt' and 'LANG' not in os.environ: try: @@ -88,69 +57,66 @@ def init(): #gettext.install('pysol', locale_dir, unicode=True) # ngettext don't work gettext.bindtextdomain('pysol', locale_dir) gettext.textdomain('pysol') - import __builtin__ - __builtin__._ = gettext.ugettext # use unicode - __builtin__.n_ = lambda x: x ## debug if 'PYSOL_CHECK_GAMES' in os.environ or 'PYSOL_DEBUG' in os.environ: - settings.CHECK_GAMES = True + pysollib.settings.CHECK_GAMES = True print 'PySol debugging: set CHECK_GAMES to True' if 'PYSOL_DEBUG' in os.environ: try: - settings.DEBUG = int(os.environ['PYSOL_DEBUG']) + pysollib.settings.DEBUG = int(os.environ['PYSOL_DEBUG']) except: - settings.DEBUG = 1 - print 'PySol debugging: set DEBUG to', settings.DEBUG + pysollib.settings.DEBUG = 1 + print 'PySol debugging: set DEBUG to', pysollib.settings.DEBUG ## init toolkit if '--gtk' in sys.argv: - settings.TOOLKIT = 'gtk' + pysollib.settings.TOOLKIT = 'gtk' sys.argv.remove('--gtk') elif '--tk' in sys.argv: - settings.TOOLKIT = 'tk' - settings.USE_TILE = False + pysollib.settings.TOOLKIT = 'tk' + pysollib.settings.USE_TILE = False sys.argv.remove('--tk') elif '--tile' in sys.argv: - settings.TOOLKIT = 'tk' - settings.USE_TILE = True + pysollib.settings.TOOLKIT = 'tk' + pysollib.settings.USE_TILE = True sys.argv.remove('--tile') - if settings.TOOLKIT == 'tk': + if pysollib.settings.TOOLKIT == 'tk': import Tkinter - root = Tkinter.Tk(className=settings.TITLE) + root = Tkinter.Tk(className=pysollib.settings.TITLE) root.withdraw() if Tkinter.TkVersion < 8.4: # we need unicode support sys.exit("%s needs Tcl/Tk 8.4 or better (you have %s)" % - (settings.TITLE, str(Tkinter.TkVersion))) - settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem') - if settings.WIN_SYSTEM == 'aqua': + (pysollib.settings.TITLE, str(Tkinter.TkVersion))) + pysollib.settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem') + if pysollib.settings.WIN_SYSTEM == 'aqua': # TkAqua displays the console automatically in application # bundles, so we hide it here. - from macosx.appSupport import hideTkConsole + from pysollib.macosx.appSupport import hideTkConsole hideTkConsole(root) # - if settings.USE_TILE == 'auto': + if pysollib.settings.USE_TILE == 'auto': # check Tile - settings.USE_TILE = False + pysollib.settings.USE_TILE = False try: root.tk.eval('package require tile 0.7.8') except Tkinter.TclError: pass else: - settings.USE_TILE = True + pysollib.settings.USE_TILE = True # "can't invoke event <>: application has been destroyed" #root.destroy() Tkinter._default_root = None # check FreeCell-Solver - settings.USE_FREECELL_SOLVER = False + pysollib.settings.USE_FREECELL_SOLVER = False if os.name == 'nt': if sys.path[0] and not os.path.isdir(sys.path[0]): # i.e. library.zip d = os.path.dirname(sys.path[0]) os.chdir(d) # for read presets fcs_command = os.path.join('freecell-solver', 'bin', 'fc-solve.exe') - settings.FCS_COMMAND = fcs_command + pysollib.settings.FCS_COMMAND = fcs_command f = os.path.join('freecell-solver', 'presetrc') os.environ['FREECELL_SOLVER_PRESETRC'] = f if os.name in ('posix', 'nt'): @@ -161,10 +127,10 @@ def init(): 'stdin': subprocess.PIPE,} if os.name != 'nt': kw['close_fds'] = True - p = subprocess.Popen(settings.FCS_COMMAND+' --help', **kw) + p = subprocess.Popen(pysollib.settings.FCS_COMMAND+' --help', **kw) p.stdin.close() if p.stdout.readline().startswith('fc-solve'): - settings.USE_FREECELL_SOLVER = True + pysollib.settings.USE_FREECELL_SOLVER = True if os.name == 'posix': os.wait() # kill zombi except: @@ -175,5 +141,5 @@ def init(): # run app without games menus (more fast start) if '--no-games-menu' in sys.argv: sys.argv.remove('--no-games-menu') - settings.SELECT_GAME_MENU = False + pysollib.settings.SELECT_GAME_MENU = False diff --git a/pysollib/layout.py b/pysollib/layout.py index 490e56c6..f8a8459d 100644 --- a/pysollib/layout.py +++ b/pysollib/layout.py @@ -25,9 +25,9 @@ # imports # PySol imports -from mfxutil import Struct +from pysollib.mfxutil import Struct from pysollib.pysoltk import MfxCanvasText -from resource import CSI +from pysollib.resource import CSI # ************************************************************************ diff --git a/pysollib/main.py b/pysollib/main.py index 23dc30b0..b4dc8233 100644 --- a/pysollib/main.py +++ b/pysollib/main.py @@ -28,22 +28,26 @@ import traceback import getopt # PySol imports -from util import DataLoader -from mfxutil import print_err -from resource import Tile +from pysollib.mygettext import _, n_ +from pysollib.util import DataLoader +from pysollib.mfxutil import print_err +from pysollib.resource import Tile from pysollib.app import Application -from gamedb import GAME_DB -from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient -from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient -from settings import TITLE, SOUND_MOD -from winsystems import init_root_window +from pysollib.gamedb import GAME_DB +from pysollib.pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient +from pysollib.pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient +from pysollib.settings import TITLE, SOUND_MOD +from pysollib.winsystems import init_root_window # Toolkit imports from pysollib.pysoltk import loadImage from pysollib.pysoltk import MfxMessageDialog from pysollib.pysoltk import MfxRoot from pysollib.pysoltk import PysolProgressBar +<<<<<<< HEAD +======= +>>>>>>> solver_dialog_remove_so_called_solving_method # ************************************************************************ # * @@ -212,11 +216,11 @@ def pysol_init(app, args): def progressCallback(*args): app.intro.progress.update(step=1) GAME_DB.setCallback(progressCallback) - import games + import pysollib.games if not opts['french-only']: - import games.ultra - import games.mahjongg - import games.special + import pysollib.games.ultra + import pysollib.games.mahjongg + import pysollib.games.special # try to load plugins if not opts["noplugins"]: diff --git a/pysollib/mfxutil.py b/pysollib/mfxutil.py index d0c00900..b71d1254 100644 --- a/pysollib/mfxutil.py +++ b/pysollib/mfxutil.py @@ -36,7 +36,7 @@ try: except: thread = None -from settings import PACKAGE, TOOLKIT, USE_TILE +from pysollib.settings import PACKAGE, TOOLKIT, USE_TILE Image = ImageTk = ImageOps = None if TOOLKIT == 'tk': diff --git a/pysollib/mygettext.py b/pysollib/mygettext.py new file mode 100644 index 00000000..0b51a7c5 --- /dev/null +++ b/pysollib/mygettext.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- mode: python; coding: utf-8; -*- + +import gettext + +def n_(x): + return x + +def fix_gettext(): + def ugettext(message): + # unicoded gettext + if not isinstance(message, unicode): + message = unicode(message, 'utf-8') + domain = gettext._current_domain + try: + t = gettext.translation(domain, + gettext._localedirs.get(domain, None)) + except IOError: + return message + return t.ugettext(message) + gettext.ugettext = ugettext + def ungettext(msgid1, msgid2, n): + # unicoded ngettext + if not isinstance(msgid1, unicode): + msgid1 = unicode(msgid1, 'utf-8') + if not isinstance(msgid2, unicode): + msgid2 = unicode(msgid2, 'utf-8') + domain = gettext._current_domain + try: + t = gettext.translation(domain, + gettext._localedirs.get(domain, None)) + except IOError: + if n == 1: + return msgid1 + else: + return msgid2 + return t.ungettext(msgid1, msgid2, n) + gettext.ungettext = ungettext + +fix_gettext() +_ = gettext.ugettext diff --git a/pysollib/options.py b/pysollib/options.py index 4c426114..e1b725c6 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -34,6 +34,7 @@ import pysollib.settings # Toolkit imports from pysollib.pysoltk import TOOLBAR_BUTTONS +from pysollib.mygettext import _, n_ # ************************************************************************ # * Options diff --git a/pysollib/pysolgtk/colorsdialog.py b/pysollib/pysolgtk/colorsdialog.py index d869c3fb..5ef2dea0 100644 --- a/pysollib/pysolgtk/colorsdialog.py +++ b/pysollib/pysolgtk/colorsdialog.py @@ -24,6 +24,7 @@ __all__ = ['ColorsDialog'] # imports +from pysollib.mygettext import _, n_ ## import os, sys import gtk, gobject, pango import gtk.glade diff --git a/pysollib/pysolgtk/fontsdialog.py b/pysollib/pysolgtk/fontsdialog.py index 934ff887..e26291d5 100644 --- a/pysollib/pysolgtk/fontsdialog.py +++ b/pysollib/pysolgtk/fontsdialog.py @@ -30,6 +30,7 @@ import gtk, gobject, pango import gtk.glade # PySol imports +from pysollib.mygettext import _, n_ from tkutil import create_pango_font_desc diff --git a/pysollib/pysolgtk/menubar.py b/pysollib/pysolgtk/menubar.py index 0112dcf3..338ef075 100644 --- a/pysollib/pysolgtk/menubar.py +++ b/pysollib/pysolgtk/menubar.py @@ -29,6 +29,7 @@ import gtk from gtk import gdk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.gamedb import GI from pysollib.settings import TITLE diff --git a/pysollib/pysolgtk/playeroptionsdialog.py b/pysollib/pysolgtk/playeroptionsdialog.py index 6012fb72..371f0292 100644 --- a/pysollib/pysolgtk/playeroptionsdialog.py +++ b/pysollib/pysolgtk/playeroptionsdialog.py @@ -27,6 +27,7 @@ __all__ = ['PlayerOptionsDialog'] import gobject, gtk # PySol imports +from pysollib.mygettext import _, n_ # Toolkit imports from tkwidget import MfxDialog diff --git a/pysollib/pysolgtk/selectcardset.py b/pysollib/pysolgtk/selectcardset.py index 906e1f52..e511b112 100644 --- a/pysollib/pysolgtk/selectcardset.py +++ b/pysollib/pysolgtk/selectcardset.py @@ -27,6 +27,7 @@ import os, re, sys, types import gtk, gobject # PySol imports +from pysollib.mygettext import _, n_ from pysollib.resource import CSI from pysollib.mfxutil import kwdefault diff --git a/pysollib/pysolgtk/selectgame.py b/pysollib/pysolgtk/selectgame.py index 9c0d9e36..5539d757 100644 --- a/pysollib/pysolgtk/selectgame.py +++ b/pysollib/pysolgtk/selectgame.py @@ -29,6 +29,7 @@ import gtk, gobject #from UserList import UserList # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import destruct, Struct, KwStruct from pysollib.mfxutil import kwdefault from pysollib.mfxutil import format_time diff --git a/pysollib/pysolgtk/selecttile.py b/pysollib/pysolgtk/selecttile.py index ccd51e80..c8281e07 100644 --- a/pysollib/pysolgtk/selecttile.py +++ b/pysollib/pysolgtk/selecttile.py @@ -30,6 +30,7 @@ from gtk import gdk # PySol imports ## from pysollib.mfxutil import destruct, Struct, KwStruct +from pysollib.mygettext import _, n_ from pysollib.resource import CSI from pysollib.mfxutil import kwdefault diff --git a/pysollib/pysolgtk/soundoptionsdialog.py b/pysollib/pysolgtk/soundoptionsdialog.py index 7e09b1ff..8437ce77 100644 --- a/pysollib/pysolgtk/soundoptionsdialog.py +++ b/pysollib/pysolgtk/soundoptionsdialog.py @@ -28,6 +28,7 @@ import gtk from gtk import glade # PySol imports +from pysollib.mygettext import _, n_ # Toolkit imports from tkwidget import MfxDialog diff --git a/pysollib/pysolgtk/statusbar.py b/pysollib/pysolgtk/statusbar.py index c3333ee3..5c4ffa22 100644 --- a/pysollib/pysolgtk/statusbar.py +++ b/pysollib/pysolgtk/statusbar.py @@ -27,6 +27,7 @@ import os, sys import gtk # PySol imports +from pysollib.mygettext import _, n_ # ************************************************************************ diff --git a/pysollib/pysolgtk/timeoutsdialog.py b/pysollib/pysolgtk/timeoutsdialog.py index ab7f2e3c..6c7b0989 100644 --- a/pysollib/pysolgtk/timeoutsdialog.py +++ b/pysollib/pysolgtk/timeoutsdialog.py @@ -25,6 +25,7 @@ __all__ = ['TimeoutsDialog'] # imports ## import os, sys +from pysollib.mygettext import _, n_ import gtk, gobject, pango import gtk.glade diff --git a/pysollib/pysolgtk/tkhtml.py b/pysollib/pysolgtk/tkhtml.py index b93777aa..6b8831e7 100644 --- a/pysollib/pysolgtk/tkhtml.py +++ b/pysollib/pysolgtk/tkhtml.py @@ -27,6 +27,7 @@ __all__ = ['HTMLViewer'] import os, sys, re, types import htmllib, formatter import traceback +from pysollib.mygettext import _, n_ import gtk, pango, gobject from gtk import gdk diff --git a/pysollib/pysolgtk/tkstats.py b/pysollib/pysolgtk/tkstats.py index afb67ff0..86769996 100644 --- a/pysollib/pysolgtk/tkstats.py +++ b/pysollib/pysolgtk/tkstats.py @@ -28,6 +28,7 @@ import gtk, gobject, pango import gtk.glade # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import format_time from pysollib.settings import TOP_TITLE, TITLE from pysollib.stats import PysolStatsFormatter diff --git a/pysollib/pysolgtk/tkwidget.py b/pysollib/pysolgtk/tkwidget.py index f474b7e5..a3f5106d 100644 --- a/pysollib/pysolgtk/tkwidget.py +++ b/pysollib/pysolgtk/tkwidget.py @@ -29,6 +29,7 @@ import gtk gdk = gtk.gdk # PySol imports +from pysollib.mygettext import _, n_ # Toolkit imports from tkutil import makeToplevel, setTransient, wm_withdraw diff --git a/pysollib/pysolrandom.py b/pysollib/pysolrandom.py index d010da47..375ff96b 100644 --- a/pysollib/pysolrandom.py +++ b/pysollib/pysolrandom.py @@ -25,7 +25,8 @@ # imports import sys, re, time import random -from mfxutil import SubclassResponsibility +from pysollib.mygettext import _, n_ +from pysollib.mfxutil import SubclassResponsibility # ************************************************************************ diff --git a/pysollib/resource.py b/pysollib/resource.py index b508c909..5eda1ae2 100644 --- a/pysollib/resource.py +++ b/pysollib/resource.py @@ -26,9 +26,10 @@ import os, glob, traceback # PySol imports -from mfxutil import Struct, KwStruct -from settings import DEBUG +from pysollib.mfxutil import Struct, KwStruct +from pysollib.settings import DEBUG +from pysollib.mygettext import _ # ************************************************************************ # * Abstract diff --git a/pysollib/stack.py b/pysollib/stack.py index e1c68d92..02ca7fcb 100644 --- a/pysollib/stack.py +++ b/pysollib/stack.py @@ -95,11 +95,12 @@ __all__ = ['cardsFaceUp', # imports import types +from pysollib.mygettext import _, n_ # PySol imports -from mfxutil import Struct, kwdefault, SubclassResponsibility -from mfxutil import Image, ImageTk, USE_PIL -from util import ACE, KING -from util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK +from pysollib.mfxutil import Struct, kwdefault, SubclassResponsibility +from pysollib.mfxutil import Image, ImageTk, USE_PIL +from pysollib.util import ACE, KING +from pysollib.util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK from pysollib.pysoltk import EVENT_HANDLED, EVENT_PROPAGATE from pysollib.pysoltk import CURSOR_DRAG, CURSOR_DOWN_ARROW from pysollib.pysoltk import ANCHOR_NW, ANCHOR_SE @@ -108,9 +109,14 @@ from pysollib.pysoltk import after, after_idle, after_cancel from pysollib.pysoltk import MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle, MfxCanvasText, MfxCanvasLine from pysollib.pysoltk import get_text_width from pysollib.pysoltk import markImage +<<<<<<< HEAD from settings import TOOLKIT from settings import DEBUG +======= +from pysollib.settings import TOOLKIT +from pysollib.settings import DEBUG +>>>>>>> solver_dialog_remove_so_called_solving_method # ************************************************************************ # * Let's start with some test methods for cards. diff --git a/pysollib/stats.py b/pysollib/stats.py index 16249efb..45e5bd84 100644 --- a/pysollib/stats.py +++ b/pysollib/stats.py @@ -26,8 +26,9 @@ import time # PySol imports -from mfxutil import format_time -from gamedb import GI +from pysollib.mfxutil import format_time +from pysollib.gamedb import GI +from pysollib.mygettext import _, n_ # ************************************************************************ diff --git a/pysollib/tile/colorsdialog.py b/pysollib/tile/colorsdialog.py index 7a185b05..1d406fb2 100644 --- a/pysollib/tile/colorsdialog.py +++ b/pysollib/tile/colorsdialog.py @@ -30,6 +30,7 @@ from tkColorChooser import askcolor # PySol imports from pysollib.mfxutil import KwStruct +from pysollib.mygettext import _, n_ # Toolkit imports from tkwidget import MfxDialog diff --git a/pysollib/tile/edittextdialog.py b/pysollib/tile/edittextdialog.py index 39183096..9e9e646c 100644 --- a/pysollib/tile/edittextdialog.py +++ b/pysollib/tile/edittextdialog.py @@ -29,6 +29,7 @@ import ttk # PySol imports from pysollib.mfxutil import KwStruct +from pysollib.mygettext import _, n_ # Toolkit imports from tkwidget import MfxDialog diff --git a/pysollib/tile/findcarddialog.py b/pysollib/tile/findcarddialog.py index 2f57d979..e63877f6 100644 --- a/pysollib/tile/findcarddialog.py +++ b/pysollib/tile/findcarddialog.py @@ -29,6 +29,7 @@ __all__ = ['create_find_card_dialog', # imports import os import Tkinter +from pysollib.mygettext import _, n_ # Toolkit imports from tkutil import after, after_cancel diff --git a/pysollib/tile/fontsdialog.py b/pysollib/tile/fontsdialog.py index c367abf1..2a297c09 100644 --- a/pysollib/tile/fontsdialog.py +++ b/pysollib/tile/fontsdialog.py @@ -30,6 +30,7 @@ import tkFont # PySol imports from pysollib.mfxutil import KwStruct +from pysollib.mygettext import _, n_ # Toolkit imports from tkwidget import MfxDialog diff --git a/pysollib/tile/gameinfodialog.py b/pysollib/tile/gameinfodialog.py index 83e4cfbc..c53af971 100644 --- a/pysollib/tile/gameinfodialog.py +++ b/pysollib/tile/gameinfodialog.py @@ -28,6 +28,7 @@ __all__ = ['GameInfoDialog'] import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.gamedb import GI diff --git a/pysollib/tile/menubar.py b/pysollib/tile/menubar.py index 8a77076e..ab9f5228 100644 --- a/pysollib/tile/menubar.py +++ b/pysollib/tile/menubar.py @@ -30,6 +30,7 @@ import ttk import tkFileDialog # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import Struct, kwdefault from pysollib.mfxutil import Image, USE_PIL from pysollib.util import CARDSET diff --git a/pysollib/tile/playeroptionsdialog.py b/pysollib/tile/playeroptionsdialog.py index 058f8101..c39817a9 100644 --- a/pysollib/tile/playeroptionsdialog.py +++ b/pysollib/tile/playeroptionsdialog.py @@ -28,6 +28,7 @@ import Tkinter import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tile/selectcardset.py b/pysollib/tile/selectcardset.py index 603f5526..5b3cc0e5 100644 --- a/pysollib/tile/selectcardset.py +++ b/pysollib/tile/selectcardset.py @@ -30,6 +30,7 @@ import Tkinter import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct, USE_PIL from pysollib.util import CARDSET from pysollib.resource import CSI diff --git a/pysollib/tile/selectgame.py b/pysollib/tile/selectgame.py index f9bfa4e0..825e38f5 100644 --- a/pysollib/tile/selectgame.py +++ b/pysollib/tile/selectgame.py @@ -28,10 +28,10 @@ import ttk from UserList import UserList # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import destruct, Struct, KwStruct from pysollib.mfxutil import format_time from pysollib.gamedb import GI -from pysollib.help import help_html from pysollib.resource import CSI # Toolkit imports @@ -309,6 +309,7 @@ class SelectGameDialog(MfxDialog): if not doc: return dir = os.path.join("html", "rules") + from pysollib.help import help_html help_html(self.app, doc, dir, self.top) return MfxDialog.mDone(self, button) diff --git a/pysollib/tile/selecttile.py b/pysollib/tile/selecttile.py index 341febe7..a1861a85 100644 --- a/pysollib/tile/selecttile.py +++ b/pysollib/tile/selecttile.py @@ -28,6 +28,7 @@ import ttk import tkColorChooser # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tile/solverdialog.py b/pysollib/tile/solverdialog.py index 0ec917a2..05aa84bc 100644 --- a/pysollib/tile/solverdialog.py +++ b/pysollib/tile/solverdialog.py @@ -34,6 +34,7 @@ import Tkinter import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.settings import TITLE from pysollib.mfxutil import KwStruct @@ -90,23 +91,6 @@ class SolverDialog(MfxDialog): cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2) self.games_var = cb - # - row += 1 - ttk.Label(frame, text=_('Solving method:'), anchor='w' - ).grid(row=row, column=0, sticky='ew', padx=2, pady=2) - ##sm = self.solving_methods.values() - ##sm.sort() - sm = ['A*', - 'Breadth-First Search', - 'Depth-First Search', - 'A randomized DFS', - ##'"Soft" DFS' - ] - cb = PysolCombo(frame, values=tuple(sm), state='readonly') - cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2) - cb.current(sm.index('Depth-First Search')) - self.solving_method_var = cb - # row += 1 ttk.Label(frame, text=_('Preset:'), anchor='w' @@ -246,13 +230,11 @@ class SolverDialog(MfxDialog): game = self.app.game solver = game.Solver_Class(game, self) # create solver instance game.solver = solver - method = self.solving_method_var.get() - method = self.solving_methods[method] preset = self.preset_var.get() max_iters = self.max_iters_var.get() max_depth = self.max_depth_var.get() progress = self.progress_var.get() - solver.config(method=method, preset=preset, max_iters=max_iters, + solver.config(preset=preset, max_iters=max_iters, max_depth=max_depth, progress=progress) solver.computeHints() hints_len = len(solver.hints)-1 diff --git a/pysollib/tile/soundoptionsdialog.py b/pysollib/tile/soundoptionsdialog.py index 22806b51..e6c4bb19 100644 --- a/pysollib/tile/soundoptionsdialog.py +++ b/pysollib/tile/soundoptionsdialog.py @@ -29,6 +29,7 @@ import Tkinter import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.settings import TITLE from pysollib.pysolaudio import pysolsoundserver diff --git a/pysollib/tile/statusbar.py b/pysollib/tile/statusbar.py index 6fa0faa9..41590932 100644 --- a/pysollib/tile/statusbar.py +++ b/pysollib/tile/statusbar.py @@ -29,6 +29,7 @@ import os, sys import Tkinter import ttk +from pysollib.mygettext import _, n_ if __name__ == '__main__': d = os.path.abspath(os.path.join(sys.path[0], os.pardir, os.pardir)) sys.path.append(d) diff --git a/pysollib/tile/timeoutsdialog.py b/pysollib/tile/timeoutsdialog.py index 8583a338..5212b92c 100644 --- a/pysollib/tile/timeoutsdialog.py +++ b/pysollib/tile/timeoutsdialog.py @@ -28,6 +28,7 @@ import Tkinter import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tile/tkconst.py b/pysollib/tile/tkconst.py index 7170cc15..e844ccee 100644 --- a/pysollib/tile/tkconst.py +++ b/pysollib/tile/tkconst.py @@ -41,6 +41,7 @@ __all__ = ['EVENT_HANDLED', # imports import Tkinter +from pysollib.mygettext import _, n_ # ************************************************************************ # * constants diff --git a/pysollib/tile/tkhtml.py b/pysollib/tile/tkhtml.py index 45c1a5a2..381df3e6 100644 --- a/pysollib/tile/tkhtml.py +++ b/pysollib/tile/tkhtml.py @@ -36,6 +36,7 @@ if __name__ == '__main__': gettext.install('pysol', d, unicode=True) # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import Struct, openURL from pysollib.settings import TITLE diff --git a/pysollib/tile/tkstats.py b/pysollib/tile/tkstats.py index cd383dc7..1f77d3fb 100644 --- a/pysollib/tile/tkstats.py +++ b/pysollib/tile/tkstats.py @@ -38,6 +38,7 @@ import ttk import tkFont # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.mfxutil import format_time ##from pysollib.util import * diff --git a/pysollib/tile/tkwidget.py b/pysollib/tile/tkwidget.py index 8094f67b..5d7fc5c9 100644 --- a/pysollib/tile/tkwidget.py +++ b/pysollib/tile/tkwidget.py @@ -39,6 +39,7 @@ import tkFont import traceback # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import destruct, kwdefault, KwStruct, openURL from pysollib.settings import WIN_SYSTEM diff --git a/pysollib/tile/toolbar.py b/pysollib/tile/toolbar.py index 4fbe2882..b21433c3 100644 --- a/pysollib/tile/toolbar.py +++ b/pysollib/tile/toolbar.py @@ -29,6 +29,7 @@ import Tkinter import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import destruct from pysollib.mfxutil import Image, ImageTk, ImageOps from pysollib.util import IMAGE_EXTENSIONS diff --git a/pysollib/tile/ttk.py b/pysollib/tile/ttk.py index 44e42f10..e6845eb0 100644 --- a/pysollib/tile/ttk.py +++ b/pysollib/tile/ttk.py @@ -26,6 +26,7 @@ __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label", "tclobjs_to_py"] import Tkinter +from pysollib.mygettext import _, n_ _flatten = Tkinter._flatten diff --git a/pysollib/tile/wizarddialog.py b/pysollib/tile/wizarddialog.py index ad37033a..955a63ac 100644 --- a/pysollib/tile/wizarddialog.py +++ b/pysollib/tile/wizarddialog.py @@ -29,6 +29,7 @@ import Tkinter import ttk # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.wizardutil import WizardWidgets from pysollib.wizardpresets import presets diff --git a/pysollib/tk/colorsdialog.py b/pysollib/tk/colorsdialog.py index 2fd29050..a831288c 100644 --- a/pysollib/tk/colorsdialog.py +++ b/pysollib/tk/colorsdialog.py @@ -28,6 +28,7 @@ import Tkinter from tkColorChooser import askcolor # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tk/edittextdialog.py b/pysollib/tk/edittextdialog.py index bcf01a10..407b2c5b 100644 --- a/pysollib/tk/edittextdialog.py +++ b/pysollib/tk/edittextdialog.py @@ -27,6 +27,7 @@ __all__ = ['EditTextDialog'] import Tkinter # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tk/findcarddialog.py b/pysollib/tk/findcarddialog.py index 0ac79554..3e7d3def 100644 --- a/pysollib/tk/findcarddialog.py +++ b/pysollib/tk/findcarddialog.py @@ -32,6 +32,7 @@ import Tkinter ##import traceback # PySol imports +from pysollib.mygettext import _, n_ # Toolkit imports from tkutil import after, after_cancel diff --git a/pysollib/tk/fontsdialog.py b/pysollib/tk/fontsdialog.py index a42405b8..4fae3328 100644 --- a/pysollib/tk/fontsdialog.py +++ b/pysollib/tk/fontsdialog.py @@ -28,6 +28,7 @@ import Tkinter import tkFont # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tk/gameinfodialog.py b/pysollib/tk/gameinfodialog.py index 1d129594..2731e5de 100644 --- a/pysollib/tk/gameinfodialog.py +++ b/pysollib/tk/gameinfodialog.py @@ -28,6 +28,7 @@ __all__ = ['GameInfoDialog'] import Tkinter # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.gamedb import GI diff --git a/pysollib/tk/menubar.py b/pysollib/tk/menubar.py index def96b2c..ac1b4a09 100644 --- a/pysollib/tk/menubar.py +++ b/pysollib/tk/menubar.py @@ -29,6 +29,7 @@ import traceback import Tkinter, tkFileDialog # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import Struct, kwdefault from pysollib.mfxutil import Image, USE_PIL from pysollib.util import CARDSET diff --git a/pysollib/tk/playeroptionsdialog.py b/pysollib/tk/playeroptionsdialog.py index d5470fe8..c46af7e5 100644 --- a/pysollib/tk/playeroptionsdialog.py +++ b/pysollib/tk/playeroptionsdialog.py @@ -27,6 +27,7 @@ __all__ = ['PlayerOptionsDialog'] import Tkinter # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct, Struct # Toolkit imports diff --git a/pysollib/tk/selectcardset.py b/pysollib/tk/selectcardset.py index 1b42c296..e7ecf1ec 100644 --- a/pysollib/tk/selectcardset.py +++ b/pysollib/tk/selectcardset.py @@ -28,6 +28,7 @@ import os import Tkinter # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct, USE_PIL from pysollib.util import CARDSET from pysollib.resource import CSI diff --git a/pysollib/tk/selectgame.py b/pysollib/tk/selectgame.py index 68a98041..7846d0b1 100644 --- a/pysollib/tk/selectgame.py +++ b/pysollib/tk/selectgame.py @@ -28,6 +28,7 @@ import Tkinter from UserList import UserList # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import destruct, Struct, KwStruct from pysollib.mfxutil import format_time from pysollib.gamedb import GI diff --git a/pysollib/tk/selecttile.py b/pysollib/tk/selecttile.py index 2d5491cc..d0528a98 100644 --- a/pysollib/tk/selecttile.py +++ b/pysollib/tk/selecttile.py @@ -26,6 +26,7 @@ import Tkinter, tkColorChooser # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tk/solverdialog.py b/pysollib/tk/solverdialog.py index 24ef810f..cc27f4cc 100644 --- a/pysollib/tk/solverdialog.py +++ b/pysollib/tk/solverdialog.py @@ -34,6 +34,7 @@ import Tkinter ##import traceback # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.settings import TITLE @@ -93,23 +94,6 @@ class SolverDialog(MfxDialog): for i in xrange(cb_max, n, cb_max): om['menu'].entryconfig(i, columnbreak=True) - # - row += 1 - Tkinter.Label(frame, text=_('Solving method:'), anchor='w' - ).grid(row=row, column=0, sticky='ew', padx=2, pady=2) - ##sm = self.solving_methods.values() - ##sm.sort() - sm = ['A*', - 'Breadth-First Search', - 'Depth-First Search', - 'A randomized DFS', - ##'"Soft" DFS' - ] - self.solving_method_var = var = Tkinter.StringVar() - var.set('Depth-First Search') - om = Tkinter.OptionMenu(frame, var, *sm) - om.grid(row=row, column=1, sticky='ew', padx=2, pady=2) - # row += 1 Tkinter.Label(frame, text=_('Preset:'), anchor='w' @@ -249,13 +233,11 @@ class SolverDialog(MfxDialog): game = self.app.game solver = game.Solver_Class(game, self) # create solver instance game.solver = solver - method = self.solving_method_var.get() - method = self.solving_methods[method] preset = self.preset_var.get() max_iters = self.max_iters_var.get() max_depth = self.max_depth_var.get() progress = self.progress_var.get() - solver.config(method=method, preset=preset, max_iters=max_iters, + solver.config(preset=preset, max_iters=max_iters, max_depth=max_depth, progress=progress) solver.computeHints() hints_len = len(solver.hints)-1 diff --git a/pysollib/tk/soundoptionsdialog.py b/pysollib/tk/soundoptionsdialog.py index c5e816f3..f66011ac 100644 --- a/pysollib/tk/soundoptionsdialog.py +++ b/pysollib/tk/soundoptionsdialog.py @@ -28,6 +28,7 @@ import os import Tkinter # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.settings import TITLE from pysollib.pysolaudio import pysolsoundserver diff --git a/pysollib/tk/statusbar.py b/pysollib/tk/statusbar.py index c20380d6..c433022b 100644 --- a/pysollib/tk/statusbar.py +++ b/pysollib/tk/statusbar.py @@ -34,6 +34,7 @@ if __name__ == '__main__': gettext.install('pysol', d, unicode=True) # PySol imports +from pysollib.mygettext import _, n_ # Toolkit imports from tkwidget import MfxTooltip diff --git a/pysollib/tk/timeoutsdialog.py b/pysollib/tk/timeoutsdialog.py index e4e1aa2f..b9833830 100644 --- a/pysollib/tk/timeoutsdialog.py +++ b/pysollib/tk/timeoutsdialog.py @@ -27,6 +27,7 @@ __all__ = ['TimeoutsDialog'] import Tkinter # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct # Toolkit imports diff --git a/pysollib/tk/tkconst.py b/pysollib/tk/tkconst.py index 7170cc15..e844ccee 100644 --- a/pysollib/tk/tkconst.py +++ b/pysollib/tk/tkconst.py @@ -41,6 +41,7 @@ __all__ = ['EVENT_HANDLED', # imports import Tkinter +from pysollib.mygettext import _, n_ # ************************************************************************ # * constants diff --git a/pysollib/tk/tkhtml.py b/pysollib/tk/tkhtml.py index 4dc4da0d..f0b36553 100644 --- a/pysollib/tk/tkhtml.py +++ b/pysollib/tk/tkhtml.py @@ -35,6 +35,7 @@ if __name__ == '__main__': gettext.install('pysol', d, unicode=True) # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import Struct, openURL from pysollib.settings import TITLE diff --git a/pysollib/tk/tkstats.py b/pysollib/tk/tkstats.py index 73bea2a0..6ab0f6f4 100644 --- a/pysollib/tk/tkstats.py +++ b/pysollib/tk/tkstats.py @@ -36,6 +36,7 @@ import time import Tkinter, tkFont # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import kwdefault, KwStruct from pysollib.mfxutil import format_time ##from pysollib.util import * diff --git a/pysollib/tk/tkwidget.py b/pysollib/tk/tkwidget.py index 91694560..f41637da 100644 --- a/pysollib/tk/tkwidget.py +++ b/pysollib/tk/tkwidget.py @@ -38,6 +38,7 @@ import tkFont import traceback # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import destruct, kwdefault, KwStruct, openURL from pysollib.settings import WIN_SYSTEM diff --git a/pysollib/tk/toolbar.py b/pysollib/tk/toolbar.py index d02bb061..62bc98b5 100644 --- a/pysollib/tk/toolbar.py +++ b/pysollib/tk/toolbar.py @@ -28,6 +28,7 @@ import os import Tkinter # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import destruct from pysollib.mfxutil import Image, ImageTk from pysollib.util import IMAGE_EXTENSIONS diff --git a/pysollib/tk/wizarddialog.py b/pysollib/tk/wizarddialog.py index 5592eb91..3294b652 100644 --- a/pysollib/tk/wizarddialog.py +++ b/pysollib/tk/wizarddialog.py @@ -29,6 +29,7 @@ import Tkinter from tabpage import TabPageSet # PySol imports +from pysollib.mygettext import _, n_ from pysollib.mfxutil import KwStruct from pysollib.wizardutil import WizardWidgets from pysollib.wizardpresets import presets diff --git a/pysollib/util.py b/pysollib/util.py index 8de3f007..0c01765b 100644 --- a/pysollib/util.py +++ b/pysollib/util.py @@ -49,9 +49,10 @@ __all__ = ['SUITS', import sys, os # PySol imports -from settings import DATA_DIRS, TOOLKIT -from mfxutil import Image +from pysollib.settings import DATA_DIRS, TOOLKIT +from pysollib.mfxutil import Image +from pysollib.mygettext import _, n_ # ************************************************************************ # * constants diff --git a/pysollib/winsystems/common.py b/pysollib/winsystems/common.py index a5c093ca..7987b935 100644 --- a/pysollib/winsystems/common.py +++ b/pysollib/winsystems/common.py @@ -23,6 +23,7 @@ import sys, os, traceback +from pysollib.mygettext import _, n_ from pysollib.settings import TITLE from pysollib.settings import VERSION from pysollib.settings import TOOLKIT, USE_TILE diff --git a/pysollib/wizardpresets.py b/pysollib/wizardpresets.py index ee471527..2f2a4b4f 100644 --- a/pysollib/wizardpresets.py +++ b/pysollib/wizardpresets.py @@ -21,6 +21,8 @@ ## ##---------------------------------------------------------------------------## +from pysollib.mygettext import n_ + presets = { 'None': { 'preset': 'None', diff --git a/pysollib/wizardutil.py b/pysollib/wizardutil.py index fa75083f..3352d170 100644 --- a/pysollib/wizardutil.py +++ b/pysollib/wizardutil.py @@ -23,12 +23,13 @@ import os -from gamedb import GI, loadGame -from util import * -from stack import * -from layout import Layout +from pysollib.gamedb import GI, loadGame +from pysollib.util import * +from pysollib.stack import * +from pysollib.layout import Layout from wizardpresets import presets +from pysollib.mygettext import _, n_ # ************************************************************************ # * @@ -348,7 +349,7 @@ WizardWidgets = ( def write_game(app, game=None): - import customgame # for py2exe + import pysollib.customgame # for py2exe if game is None: # new game diff --git a/scripts/filter-inidivual-importing-tests.pl b/scripts/filter-inidivual-importing-tests.pl new file mode 100644 index 00000000..65e95657 --- /dev/null +++ b/scripts/filter-inidivual-importing-tests.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use IO::All; +use List::MoreUtils qw(none); + +my @m2; +L_LOOP: +foreach my $l (io("scripts/gen_individual_importing_tests.py")->getlines()) +{ + if ($l =~ m/^for module_name/) + { + my @ms = $l =~ m{('pysollib\.[^']+')}g; + @m2 = (map { $_ =~ s/\A'//r =~ s/\'\z//r =~ tr#.#/#r } @ms); + last L_LOOP; + } +} + +while (my $l = ) +{ + chomp($l); + print "$l\n" if none { $l =~ /$_/ } @m2; +} diff --git a/scripts/gen_individual_importing_tests.py b/scripts/gen_individual_importing_tests.py new file mode 100644 index 00000000..a8aee5fa --- /dev/null +++ b/scripts/gen_individual_importing_tests.py @@ -0,0 +1,209 @@ +#!/usr/bin/env python +import os.path +for module_name in [ +'pysollib.acard', +'pysollib.actions', +'pysollib.app', +'pysollib.configobj.configobj', +'pysollib.configobj.validate', +'pysollib.customgame', +'pysollib.game', +'pysollib.gamedb', +'pysollib.games.acesup', +'pysollib.games.algerian', +'pysollib.games.auldlangsyne', +'pysollib.games.bakersdozen', +'pysollib.games.bakersgame', +'pysollib.games.beleagueredcastle', +'pysollib.games.bisley', +'pysollib.games.braid', +'pysollib.games.bristol', +'pysollib.games.buffalobill', +'pysollib.games.calculation', +'pysollib.games.camelot', +'pysollib.games.canfield', +'pysollib.games.capricieuse', +'pysollib.games.curdsandwhey', +'pysollib.games.dieboesesieben', +'pysollib.games.diplomat', +'pysollib.games.doublets', +'pysollib.games.eiffeltower', +'pysollib.games.fan', +'pysollib.games.fortythieves', +'pysollib.games.freecell', +'pysollib.games.glenwood', +'pysollib.games.golf', +'pysollib.games.grandduchess', +'pysollib.games.grandfathersclock', +'pysollib.games.gypsy', +'pysollib.games.harp', +'pysollib.games.headsandtails', +'pysollib.games.katzenschwanz', +'pysollib.games.klondike', +'pysollib.games.labyrinth', +'pysollib.games.larasgame', +'pysollib.games.mahjongg.mahjongg', +'pysollib.games.mahjongg.mahjongg1', +'pysollib.games.mahjongg.mahjongg2', +'pysollib.games.mahjongg.mahjongg3', +'pysollib.games.mahjongg.shisensho', +'pysollib.games.matriarchy', +'pysollib.games.montana', +'pysollib.games.montecarlo', +'pysollib.games.napoleon', +'pysollib.games.needle', +'pysollib.games.numerica', +'pysollib.games.osmosis', +'pysollib.games.parallels', +'pysollib.games.pasdedeux', +'pysollib.games.picturegallery', +'pysollib.games.pileon', +'pysollib.games.pushpin', +'pysollib.games.pyramid', +'pysollib.games.royalcotillion', +'pysollib.games.royaleast', +'pysollib.games.sanibel', +'pysollib.games.siebenbisas', +'pysollib.games.simplex', +'pysollib.games.special.hanoi', +'pysollib.games.special.memory', +'pysollib.games.special.pegged', +'pysollib.games.special.poker', +'pysollib.games.special.tarock', +'pysollib.games.spider', +'pysollib.games.sthelena', +'pysollib.games.sultan', +'pysollib.games.takeaway', +'pysollib.games.terrace', +'pysollib.games.threepeaks', +'pysollib.games.tournament', +'pysollib.games.ultra.dashavatara', +'pysollib.games.ultra.hanafuda', +'pysollib.games.ultra.hanafuda1', +'pysollib.games.ultra.hanafuda_common', +'pysollib.games.ultra.hexadeck', +'pysollib.games.ultra.larasgame', +'pysollib.games.ultra.matrix', +'pysollib.games.ultra.mughal', +'pysollib.games.ultra.tarock', +'pysollib.games.unionsquare', +'pysollib.games.wavemotion', +'pysollib.games.windmill', +'pysollib.games.yukon', +'pysollib.games.zodiac', +'pysollib.help', +'pysollib.hint', +'pysollib.images', +'pysollib.init', +'pysollib.layout', +'pysollib.macosx.appSupport', +'pysollib.main', +'pysollib.mfxutil', +'pysollib.move', +'pysollib.mygettext', +'pysollib.options', +'pysollib.pysolaudio', +'pysollib.pysolgtk.card', +'pysollib.pysolgtk.colorsdialog', +'pysollib.pysolgtk.edittextdialog', +'pysollib.pysolgtk.findcarddialog', +'pysollib.pysolgtk.fontsdialog', +'pysollib.pysolgtk.gameinfodialog', +'pysollib.pysolgtk.menubar', +'pysollib.pysolgtk.playeroptionsdialog', +'pysollib.pysolgtk.progressbar', +'pysollib.pysolgtk.pysoltree', +'pysollib.pysolgtk.selectcardset', +'pysollib.pysolgtk.selectgame', +'pysollib.pysolgtk.selecttile', +'pysollib.pysolgtk.soundoptionsdialog', +'pysollib.pysolgtk.statusbar', +'pysollib.pysolgtk.timeoutsdialog', +'pysollib.pysolgtk.tkcanvas', +'pysollib.pysolgtk.tkconst', +'pysollib.pysolgtk.tkhtml', +'pysollib.pysolgtk.tkstats', +'pysollib.pysolgtk.tkutil', +'pysollib.pysolgtk.tkwidget', +'pysollib.pysolgtk.tkwrap', +'pysollib.pysolgtk.toolbar', +'pysollib.pysolrandom', +'pysollib.pysoltk', +'pysollib.resource', +'pysollib.settings', +'pysollib.stack', +'pysollib.stats', +'pysollib.tile.card', +'pysollib.tile.colorsdialog', +'pysollib.tile.edittextdialog', +'pysollib.tile.findcarddialog', +'pysollib.tile.fontsdialog', +'pysollib.tile.gameinfodialog', +'pysollib.tile.menubar', +'pysollib.tile.playeroptionsdialog', +'pysollib.tile.progressbar', +'pysollib.tile.selectcardset', +'pysollib.tile.selectgame', +'pysollib.tile.selecttile', +'pysollib.tile.selecttree', +'pysollib.tile.solverdialog', +'pysollib.tile.soundoptionsdialog', +'pysollib.tile.statusbar', +'pysollib.tile.timeoutsdialog', +'pysollib.tile.tkcanvas', +'pysollib.tile.tkconst', +'pysollib.tile.tkhtml', +'pysollib.tile.tkstats', +'pysollib.tile.tktree', +'pysollib.tile.tkutil', +'pysollib.tile.tkwidget', +'pysollib.tile.tkwrap', +'pysollib.tile.toolbar', +'pysollib.tile.ttk', +'pysollib.tile.wizarddialog', +'pysollib.tk.card', +'pysollib.tk.colorsdialog', +'pysollib.tk.edittextdialog', +'pysollib.tk.findcarddialog', +'pysollib.tk.fontsdialog', +'pysollib.tk.gameinfodialog', +'pysollib.tk.menubar', +'pysollib.tk.playeroptionsdialog', +'pysollib.tk.progressbar', +'pysollib.tk.selectcardset', +'pysollib.tk.selectgame', +'pysollib.tk.selecttile', +'pysollib.tk.selecttree', +'pysollib.tk.solverdialog', +'pysollib.tk.soundoptionsdialog', +'pysollib.tk.statusbar', +'pysollib.tk.tabpage', +'pysollib.tk.timeoutsdialog', +'pysollib.tk.tkcanvas', +'pysollib.tk.tkconst', +'pysollib.tk.tkhtml', +'pysollib.tk.tkstats', +'pysollib.tk.tktree', +'pysollib.tk.tkutil', +'pysollib.tk.tkwidget', +'pysollib.tk.tkwrap', +'pysollib.tk.toolbar', +'pysollib.tk.wizarddialog', +'pysollib.util', +'pysollib.winsystems.aqua', +'pysollib.winsystems.common', +'pysollib.winsystems.win32', +'pysollib.winsystems.x11', +'pysollib.wizardpresets', +'pysollib.wizardutil', +]: + open(os.path.join(".", "tests", "individually-importing", "import_" + module_name + ".py"), 'w').write('''#!/usr/bin/env python +import sys +sys.path.append("./tests/lib") +from TAP.Simple import plan, ok + +plan(1) +sys.path.insert(0, ".") +import %(module_name)s +ok(1, "imported") +''' % { 'module_name': module_name }) diff --git a/tests/individually-importing/PLACEHOLDER b/tests/individually-importing/PLACEHOLDER new file mode 100644 index 00000000..e69de29b diff --git a/tests/lib/TAP/Simple.py b/tests/lib/TAP/Simple.py new file mode 100644 index 00000000..1f081030 --- /dev/null +++ b/tests/lib/TAP/Simple.py @@ -0,0 +1,37 @@ + +import TAP +import re + +builder = TAP.Builder() + +def plan(plan, plan_param=None): + builder.set_plan(plan, plan_param) + +ok = builder.ok + +def diag(comment): + print "# %s" % re.compile("\n(.)").sub(comment, '\n#\1') + +def eq_ok(have, want, comment): + okness = have == want + ok(okness, comment) + if not okness: + diag("want: %s" % want) + diag("have: %s" % have) + return okness + +def is_ok(have, want, comment): + okness = have is want + ok(okness, comment) + if not okness: + diag("want id: %s" % id(want)) + diag("have id: %s" % id(have)) + return okness + +def isa_ok(object, cls, object_name="the object"): + okness = isinstance(object, cls) + ok(okness, object_name + " is a " + repr(cls)) + # if not okness: + # diag("want id: %s" % id(want)) + # diag("have id: %s" % id(have)) + return okness diff --git a/tests/lib/TAP/__init__.py b/tests/lib/TAP/__init__.py new file mode 100644 index 00000000..5c9bfe6c --- /dev/null +++ b/tests/lib/TAP/__init__.py @@ -0,0 +1,98 @@ +import sys +import atexit + +# todo: make written-to stream passable + +class Plan(object): + def __init__(self, plan, param=None): + self.counter = 0 + self.expected_tests = None + self.ended = False + + if isinstance(plan, int): + self.expected_tests = plan + print "1..%u" % self.expected_tests + elif plan == "no_plan" or plan == None: 1 + elif plan == "skip_all": + print "1..0 # skip %s" % param + raise SystemExit(0) # ??? this is what T::B does, but sucks + else: + raise TestBadPlan(plan) + + def increment_counter(self): + self.counter += 1 + + def __del__(self): + if self.ended: return + self.ended = True + if self.expected_tests is None: + print "1..%u" % self.counter + elif self.counter != self.expected_tests: + print "# Looks like you planned %u tests but ran %u." \ + % (self.expected_tests, self.counter) + +class Builder(object): + global_defaults = { + "_plan": None, + "current": 1, + "has_plan": False, + } + global_test_builder = global_defaults.copy() + + def __init__(self, plan=None, plan_param=None): + self.__dict__ = self.global_test_builder + if plan: self.set_plan(plan, plan_param) + + @classmethod # XXX: why did this fail? + def create(cls, plan=None, plan_param=None): + # self = new.instance(cls) # ? this sucks, too + self = Builder() + self.__dict__ = self.global_defaults.copy() + if plan: self.set_plan(plan, plan_param) + return self + + def set_plan(self, plan, plan_param=None): + if self.get_plan(): raise TestPlannedAlready(plan, plan_param) + self._plan = Plan(plan, plan_param) + atexit.register(self._plan.__del__) + + def get_plan(self): return self._plan + + def ok(self, is_ok, desc=None, skip=None, todo=None): + self.get_plan().increment_counter() + if is_ok: report = "ok" + else: report = "not ok" + + sys.stdout.write("%s %u" % (report, self.current)) + + if desc: sys.stdout.write(" - %s" % desc) + if skip: sys.stdout.write(" # SKIP %s" % skip) + if todo: sys.stdout.write(" # TODO %s" % todo) + + print + + self.current += 1 + + return is_ok + + def reset(self): + self.__dict__.clear() + for key in self.global_defaults.iterkeys(): + self.__dict__[key] = self.global_defaults[key] + +class TestPlannedAlready(Exception): + def __init__(self, plan, param=None): + self.plan = plan + self.param = param + def __str__(self): + return "tried to plan twice; second plan: %s, %s" % self.plan, self.param + +class TestWithoutPlan(Exception): + def __str__(self): + return "tried running tests without a plan" + +class TestBadPlan(Exception): + def __init__(self, plan): + self.plan = plan + def __str__(self): + return "didn't understand plan '%s'" % self.plan