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:
parent
95fd883817
commit
bed5786b64
4 changed files with 33 additions and 33 deletions
|
@ -28,7 +28,7 @@ import imp
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from mfxutil import Struct, print_err
|
from mfxutil import Struct, print_err
|
||||||
from resource import CSI
|
from resource import CSI
|
||||||
import settings
|
import pysollib.settings
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -420,18 +420,18 @@ class GameInfo(Struct):
|
||||||
game_type = game_type & 1023
|
game_type = game_type & 1023
|
||||||
name = to_unicode(name)
|
name = to_unicode(name)
|
||||||
en_name = name # for app.getGameRulesFilename
|
en_name = name # for app.getGameRulesFilename
|
||||||
if settings.TRANSLATE_GAME_NAMES:
|
if pysollib.settings.TRANSLATE_GAME_NAMES:
|
||||||
name = _(name)
|
name = _(name)
|
||||||
if not short_name:
|
if not short_name:
|
||||||
short_name = name
|
short_name = name
|
||||||
else:
|
else:
|
||||||
short_name = to_unicode(short_name)
|
short_name = to_unicode(short_name)
|
||||||
if settings.TRANSLATE_GAME_NAMES:
|
if pysollib.settings.TRANSLATE_GAME_NAMES:
|
||||||
short_name = _(short_name)
|
short_name = _(short_name)
|
||||||
if isinstance(altnames, basestring):
|
if isinstance(altnames, basestring):
|
||||||
altnames = (altnames,)
|
altnames = (altnames,)
|
||||||
altnames = [to_unicode(n) for n in 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]
|
altnames = [_(n) for n in altnames]
|
||||||
#
|
#
|
||||||
if not (1 <= category <= 9):
|
if not (1 <= category <= 9):
|
||||||
|
@ -545,7 +545,7 @@ class GameManager:
|
||||||
##print gi.id, gi.short_name.encode('utf-8')
|
##print gi.id, gi.short_name.encode('utf-8')
|
||||||
if not isinstance(gi, GameInfo):
|
if not isinstance(gi, GameInfo):
|
||||||
raise GameInfoException("wrong GameInfo class")
|
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)
|
self._check_game(gi)
|
||||||
##if 0 and gi.si.game_flags & GI.GT_XORIGINAL:
|
##if 0 and gi.si.game_flags & GI.GT_XORIGINAL:
|
||||||
## return
|
## return
|
||||||
|
|
|
@ -25,7 +25,7 @@ import sys, os, locale, subprocess
|
||||||
import traceback
|
import traceback
|
||||||
import gettext
|
import gettext
|
||||||
|
|
||||||
import settings
|
import pysollib.settings
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * init
|
# * init
|
||||||
|
@ -94,63 +94,63 @@ def init():
|
||||||
|
|
||||||
## debug
|
## debug
|
||||||
if 'PYSOL_CHECK_GAMES' in os.environ or 'PYSOL_DEBUG' in os.environ:
|
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'
|
print 'PySol debugging: set CHECK_GAMES to True'
|
||||||
if 'PYSOL_DEBUG' in os.environ:
|
if 'PYSOL_DEBUG' in os.environ:
|
||||||
try:
|
try:
|
||||||
settings.DEBUG = int(os.environ['PYSOL_DEBUG'])
|
pysollib.settings.DEBUG = int(os.environ['PYSOL_DEBUG'])
|
||||||
except:
|
except:
|
||||||
settings.DEBUG = 1
|
pysollib.settings.DEBUG = 1
|
||||||
print 'PySol debugging: set DEBUG to', settings.DEBUG
|
print 'PySol debugging: set DEBUG to', pysollib.settings.DEBUG
|
||||||
|
|
||||||
## init toolkit
|
## init toolkit
|
||||||
if '--gtk' in sys.argv:
|
if '--gtk' in sys.argv:
|
||||||
settings.TOOLKIT = 'gtk'
|
pysollib.settings.TOOLKIT = 'gtk'
|
||||||
sys.argv.remove('--gtk')
|
sys.argv.remove('--gtk')
|
||||||
elif '--tk' in sys.argv:
|
elif '--tk' in sys.argv:
|
||||||
settings.TOOLKIT = 'tk'
|
pysollib.settings.TOOLKIT = 'tk'
|
||||||
settings.USE_TILE = False
|
pysollib.settings.USE_TILE = False
|
||||||
sys.argv.remove('--tk')
|
sys.argv.remove('--tk')
|
||||||
elif '--tile' in sys.argv:
|
elif '--tile' in sys.argv:
|
||||||
settings.TOOLKIT = 'tk'
|
pysollib.settings.TOOLKIT = 'tk'
|
||||||
settings.USE_TILE = True
|
pysollib.settings.USE_TILE = True
|
||||||
sys.argv.remove('--tile')
|
sys.argv.remove('--tile')
|
||||||
if settings.TOOLKIT == 'tk':
|
if pysollib.settings.TOOLKIT == 'tk':
|
||||||
import Tkinter
|
import Tkinter
|
||||||
root = Tkinter.Tk(className=settings.TITLE)
|
root = Tkinter.Tk(className=pysollib.settings.TITLE)
|
||||||
root.withdraw()
|
root.withdraw()
|
||||||
if Tkinter.TkVersion < 8.4:
|
if Tkinter.TkVersion < 8.4:
|
||||||
# we need unicode support
|
# we need unicode support
|
||||||
sys.exit("%s needs Tcl/Tk 8.4 or better (you have %s)" %
|
sys.exit("%s needs Tcl/Tk 8.4 or better (you have %s)" %
|
||||||
(settings.TITLE, str(Tkinter.TkVersion)))
|
(pysollib.settings.TITLE, str(Tkinter.TkVersion)))
|
||||||
settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem')
|
pysollib.settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem')
|
||||||
if settings.WIN_SYSTEM == 'aqua':
|
if pysollib.settings.WIN_SYSTEM == 'aqua':
|
||||||
# TkAqua displays the console automatically in application
|
# TkAqua displays the console automatically in application
|
||||||
# bundles, so we hide it here.
|
# bundles, so we hide it here.
|
||||||
from macosx.appSupport import hideTkConsole
|
from macosx.appSupport import hideTkConsole
|
||||||
hideTkConsole(root)
|
hideTkConsole(root)
|
||||||
#
|
#
|
||||||
if settings.USE_TILE == 'auto':
|
if pysollib.settings.USE_TILE == 'auto':
|
||||||
# check Tile
|
# check Tile
|
||||||
settings.USE_TILE = False
|
pysollib.settings.USE_TILE = False
|
||||||
try:
|
try:
|
||||||
root.tk.eval('package require tile 0.7.8')
|
root.tk.eval('package require tile 0.7.8')
|
||||||
except Tkinter.TclError:
|
except Tkinter.TclError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
settings.USE_TILE = True
|
pysollib.settings.USE_TILE = True
|
||||||
# "can't invoke event <<ThemeChanged>>: application has been destroyed"
|
# "can't invoke event <<ThemeChanged>>: application has been destroyed"
|
||||||
#root.destroy()
|
#root.destroy()
|
||||||
Tkinter._default_root = None
|
Tkinter._default_root = None
|
||||||
|
|
||||||
# check FreeCell-Solver
|
# check FreeCell-Solver
|
||||||
settings.USE_FREECELL_SOLVER = False
|
pysollib.settings.USE_FREECELL_SOLVER = False
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
if sys.path[0] and not os.path.isdir(sys.path[0]): # i.e. library.zip
|
if sys.path[0] and not os.path.isdir(sys.path[0]): # i.e. library.zip
|
||||||
d = os.path.dirname(sys.path[0])
|
d = os.path.dirname(sys.path[0])
|
||||||
os.chdir(d) # for read presets
|
os.chdir(d) # for read presets
|
||||||
fcs_command = os.path.join('freecell-solver', 'bin', 'fc-solve.exe')
|
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')
|
f = os.path.join('freecell-solver', 'presetrc')
|
||||||
os.environ['FREECELL_SOLVER_PRESETRC'] = f
|
os.environ['FREECELL_SOLVER_PRESETRC'] = f
|
||||||
if os.name in ('posix', 'nt'):
|
if os.name in ('posix', 'nt'):
|
||||||
|
@ -160,9 +160,9 @@ def init():
|
||||||
'stderr': subprocess.PIPE}
|
'stderr': subprocess.PIPE}
|
||||||
if os.name != 'nt':
|
if os.name != 'nt':
|
||||||
kw['close_fds'] = True
|
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'):
|
if p.stdout.readline().startswith('fc-solve'):
|
||||||
settings.USE_FREECELL_SOLVER = True
|
pysollib.settings.USE_FREECELL_SOLVER = True
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
os.wait() # kill zombi
|
os.wait() # kill zombi
|
||||||
except:
|
except:
|
||||||
|
@ -173,5 +173,5 @@ def init():
|
||||||
# run app without games menus (more fast start)
|
# run app without games menus (more fast start)
|
||||||
if '--no-games-menu' in sys.argv:
|
if '--no-games-menu' in sys.argv:
|
||||||
sys.argv.remove('--no-games-menu')
|
sys.argv.remove('--no-games-menu')
|
||||||
settings.SELECT_GAME_MENU = False
|
pysollib.settings.SELECT_GAME_MENU = False
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import traceback
|
||||||
from mfxutil import print_err
|
from mfxutil import print_err
|
||||||
from resource import CSI
|
from resource import CSI
|
||||||
from configobj import configobj, validate
|
from configobj import configobj, validate
|
||||||
import settings
|
import pysollib.settings
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from pysoltk import TOOLBAR_BUTTONS
|
from pysoltk import TOOLBAR_BUTTONS
|
||||||
|
@ -248,7 +248,7 @@ class Options:
|
||||||
self._config = None # configobj.ConfigObj instance
|
self._config = None # configobj.ConfigObj instance
|
||||||
self._config_encoding = 'utf-8'
|
self._config_encoding = 'utf-8'
|
||||||
|
|
||||||
self.version_tuple = settings.VERSION_TUPLE # XXX
|
self.version_tuple = pysollib.settings.VERSION_TUPLE # XXX
|
||||||
self.saved = 0 # XXX
|
self.saved = 0 # XXX
|
||||||
# options menu:
|
# options menu:
|
||||||
self.player = _("Unknown")
|
self.player = _("Unknown")
|
||||||
|
@ -403,7 +403,7 @@ class Options:
|
||||||
]
|
]
|
||||||
|
|
||||||
def setDefaults(self, top=None):
|
def setDefaults(self, top=None):
|
||||||
WIN_SYSTEM = settings.WIN_SYSTEM
|
WIN_SYSTEM = pysollib.settings.WIN_SYSTEM
|
||||||
# toolbar
|
# toolbar
|
||||||
#if WIN_SYSTEM == 'win32':
|
#if WIN_SYSTEM == 'win32':
|
||||||
# self.toolbar_style = 'crystal'
|
# self.toolbar_style = 'crystal'
|
||||||
|
@ -607,7 +607,7 @@ class Options:
|
||||||
elif val is not None:
|
elif val is not None:
|
||||||
setattr(self, key, val)
|
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')
|
recent_gameid = self._getOption('general', 'recent_gameid', 'list')
|
||||||
if recent_gameid is not None:
|
if recent_gameid is not None:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os.path
|
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
|
open(os.path.join(".", "tests", "individually-importing", "import_" + module_name + ".py"), 'w').write('''#!/usr/bin/env python
|
||||||
import sys
|
import sys
|
||||||
sys.path.append("./tests/lib")
|
sys.path.append("./tests/lib")
|
||||||
|
|
Loading…
Add table
Reference in a new issue