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

* fixed bug with non-ascii chars in the path

git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@219 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2008-02-29 04:13:23 +00:00
parent f7114887e4
commit 8c407dee95
6 changed files with 18 additions and 37 deletions

View file

@ -41,7 +41,7 @@ import traceback
# PySol imports # PySol imports
from mfxutil import destruct, Struct from mfxutil import destruct, Struct
from mfxutil import pickle, unpickle, UnpicklingError from mfxutil import pickle, unpickle, UnpicklingError
from mfxutil import getusername, gethomedir, getprefdir from mfxutil import getusername, getprefdir
from mfxutil import latin1_to_ascii, print_err from mfxutil import latin1_to_ascii, print_err
from util import CARDSET, IMAGE_EXTENSIONS from util import CARDSET, IMAGE_EXTENSIONS
from settings import PACKAGE, VERSION_TUPLE, WIN_SYSTEM from settings import PACKAGE, VERSION_TUPLE, WIN_SYSTEM
@ -372,10 +372,8 @@ class Application:
progress = None, # progress bar progress = None, # progress bar
) )
# directory names # directory names
home = os.path.normpath(gethomedir()) config = os.path.normpath(getprefdir(PACKAGE))
config = os.path.normpath(getprefdir(PACKAGE, home))
self.dn = Struct( self.dn = Struct(
home = home,
config = config, config = config,
plugins = os.path.join(config, "plugins"), plugins = os.path.join(config, "plugins"),
savegames = os.path.join(config, "savegames"), savegames = os.path.join(config, "savegames"),
@ -780,6 +778,7 @@ class Application:
def _getImagesDir(self, *dirs, **kwargs): def _getImagesDir(self, *dirs, **kwargs):
check = kwargs.get('check', True) check = kwargs.get('check', True)
dirs = [str(d) for d in dirs] # XXX: don't use unicode
d = os.path.join(self.dataloader.dir, 'images', *dirs) d = os.path.join(self.dataloader.dir, 'images', *dirs)
if check: if check:
if os.path.exists(d): if os.path.exists(d):
@ -1445,9 +1444,8 @@ Please select a %s type %s.
def initTiles(self): def initTiles(self):
manager = self.tabletile_manager manager = self.tabletile_manager
# find all available tiles # find all available tiles
# Note: we use a unicoded filenames
dirs = manager.getSearchDirs(self, dirs = manager.getSearchDirs(self,
(u"tiles-*", os.path.join(u"tiles", u"stretch")), ("tiles-*", os.path.join("tiles", "stretch")),
"PYSOL_TILES") "PYSOL_TILES")
##print dirs ##print dirs
s = "((\\" + ")|(\\".join(IMAGE_EXTENSIONS) + "))$" s = "((\\" + ")|(\\".join(IMAGE_EXTENSIONS) + "))$"
@ -1461,11 +1459,6 @@ Please select a %s type %s.
for name in names: for name in names:
if not name or not ext_re.search(name): if not name or not ext_re.search(name):
continue continue
if not isinstance(name, unicode):
try:
name = unicode(name)
except:
continue
f = os.path.join(dir, name) f = os.path.join(dir, name)
if not os.path.isfile(f): if not os.path.isfile(f):
continue continue

View file

@ -125,20 +125,12 @@ def getusername():
return user return user
def gethomedir(): def getprefdir(package):
if os.name == "nt": if os.name == "nt":
return win32_gethomedir() return win32_getprefdir(package)
home = os.environ.get("HOME", "").strip() home = os.environ.get("HOME", "").strip()
if not home or not os.path.isdir(home): if not home or not os.path.isdir(home):
home = os.curdir home = os.curdir
return os.path.abspath(home)
def getprefdir(package, home=None):
if os.name == "nt":
return win32_getprefdir(package)
if home is None:
home = gethomedir()
return os.path.join(home, ".PySolFC") return os.path.join(home, ".PySolFC")
@ -157,20 +149,16 @@ def win32_getusername():
return user return user
def win32_getprefdir(package): def win32_getprefdir(package):
hd = win32_gethomedir()
return os.path.join(hd, 'PySolFC')
def win32_gethomedir():
# %USERPROFILE%, %APPDATA% # %USERPROFILE%, %APPDATA%
hd = os.environ.get('APPDATA') hd = os.environ.get('APPDATA')
if hd: if not hd:
return hd hd = os.path.expanduser('~')
hd = os.path.expanduser('~') if hd == '~': # win9x
if hd == '~': # win9x hd = os.path.abspath('/windows/Application Data')
hd = os.path.abspath('/windows/Application Data') if not os.path.exists(hd):
if not os.path.exists(hd): hd = os.path.abspath('/')
hd = os.path.abspath('/') return os.path.join(hd, 'PySolFC')
return hd
# /*********************************************************************** # /***********************************************************************
# // memory util # // memory util

View file

@ -35,7 +35,7 @@
# imports # imports
import os, glob import os, glob, traceback
# PySol imports # PySol imports
from mfxutil import Struct, KwStruct from mfxutil import Struct, KwStruct
@ -157,6 +157,7 @@ class ResourceManager:
else: else:
self._addDir(result, os.path.join(dir, s)) self._addDir(result, os.path.join(dir, s))
except EnvironmentError, ex: except EnvironmentError, ex:
traceback.print_exc()
pass pass
if DEBUG >= 6: if DEBUG >= 6:
print "getSearchDirs", env, search, "->", result print "getSearchDirs", env, search, "->", result

View file

@ -756,7 +756,7 @@ class PysolMenubarTk:
self.mSelectGame, self.tkopt.gameid) self.mSelectGame, self.tkopt.gameid)
def _addSelectCustomGameSubMenu(self, games, menu, command, variable): def _addSelectCustomGameSubMenu(self, games, menu, command, variable):
submenu = MfxMenu(menu, label=n_("&Cusom games")) submenu = MfxMenu(menu, label=n_("&Custom games"))
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
games = filter(select_func, games) games = filter(select_func, games)
self.updateGamesMenu(submenu, games) self.updateGamesMenu(submenu, games)

View file

@ -760,7 +760,7 @@ class PysolMenubarTk:
self.mSelectGame, self.tkopt.gameid) self.mSelectGame, self.tkopt.gameid)
def _addSelectCustomGameSubMenu(self, games, menu, command, variable): def _addSelectCustomGameSubMenu(self, games, menu, command, variable):
submenu = MfxMenu(menu, label=n_("&Cusom games")) submenu = MfxMenu(menu, label=n_("&Custom games"))
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
games = filter(select_func, games) games = filter(select_func, games)
self.updateGamesMenu(submenu, games) self.updateGamesMenu(submenu, games)

View file

@ -5,7 +5,6 @@ rm -rf dist
mkdir dist mkdir dist
cp -r locale dist cp -r locale dist
cp -r freecell-solver dist cp -r freecell-solver dist
cp smpeg.dll ogg.dll vorbis.dll vorbisfile.dll dist
python setup.py py2exe python setup.py py2exe
cp -r d:\Python\tcl\tile0.7.8 dist\tcl cp -r d:\Python\tcl\tile0.7.8 dist\tcl
cp -r data\music dist\data cp -r data\music dist\data