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: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@219 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2008-02-29 04:13:23 +00:00
parent 7f54db1127
commit 212c8ed5ce
6 changed files with 18 additions and 37 deletions

View file

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

View file

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

View file

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

View file

@ -756,7 +756,7 @@ class PysolMenubarTk:
self.mSelectGame, self.tkopt.gameid)
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
games = filter(select_func, games)
self.updateGamesMenu(submenu, games)

View file

@ -760,7 +760,7 @@ class PysolMenubarTk:
self.mSelectGame, self.tkopt.gameid)
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
games = filter(select_func, games)
self.updateGamesMenu(submenu, games)

View file

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