1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Convert settings to pysollib.settings and test it.

This commit is contained in:
Shlomi Fish 2012-11-25 17:00:08 +02:00
parent 95fd883817
commit bed5786b64
4 changed files with 33 additions and 33 deletions

View file

@ -28,7 +28,7 @@ import imp
# PySol imports
from mfxutil import Struct, print_err
from resource import CSI
import settings
import pysollib.settings
# ************************************************************************
@ -420,18 +420,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 +545,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

View file

@ -25,7 +25,7 @@ import sys, os, locale, subprocess
import traceback
import gettext
import settings
import pysollib.settings
# ************************************************************************
# * init
@ -94,63 +94,63 @@ def init():
## 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
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 <<ThemeChanged>>: 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'):
@ -160,9 +160,9 @@ def init():
'stderr': 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)
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:
@ -173,5 +173,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

View file

@ -29,7 +29,7 @@ import traceback
from mfxutil import print_err
from resource import CSI
from configobj import configobj, validate
import settings
import pysollib.settings
# Toolkit imports
from pysoltk import TOOLBAR_BUTTONS
@ -248,7 +248,7 @@ class Options:
self._config = None # configobj.ConfigObj instance
self._config_encoding = 'utf-8'
self.version_tuple = settings.VERSION_TUPLE # XXX
self.version_tuple = pysollib.settings.VERSION_TUPLE # XXX
self.saved = 0 # XXX
# options menu:
self.player = _("Unknown")
@ -403,7 +403,7 @@ class Options:
]
def setDefaults(self, top=None):
WIN_SYSTEM = settings.WIN_SYSTEM
WIN_SYSTEM = pysollib.settings.WIN_SYSTEM
# toolbar
#if WIN_SYSTEM == 'win32':
# self.toolbar_style = 'crystal'
@ -607,7 +607,7 @@ class Options:
elif val is not None:
setattr(self, key, val)
settings.TRANSLATE_GAME_NAMES = self.translate_game_names
pysollib.settings.TRANSLATE_GAME_NAMES = self.translate_game_names
recent_gameid = self._getOption('general', 'recent_gameid', 'list')
if recent_gameid is not None:

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python
import os.path
for module_name in ['pysollib.mfxutil', 'pysollib.move',]:
for module_name in ['pysollib.mfxutil', 'pysollib.move', 'pysollib.settings',]:
open(os.path.join(".", "tests", "individually-importing", "import_" + module_name + ".py"), 'w').write('''#!/usr/bin/env python
import sys
sys.path.append("./tests/lib")