Fix read file from a zip module that points to real outside file.

bzr revid: ced-95329ecbf74237e1399443471809240fafa811c2
This commit is contained in:
ced 2007-10-16 06:27:40 +00:00
parent 8ceadbc1d6
commit ee3e6600fb
1 changed files with 6 additions and 3 deletions

View File

@ -192,9 +192,12 @@ def file_open(name, mode="r", subdir='addons'):
if zipfile.is_zipfile(head+'.zip'):
import StringIO
zfile = zipfile.ZipFile(head+'.zip')
return StringIO.StringIO(zfile.read(os.path.join(
os.path.basename(head), zipname).replace(
os.sep, '/')))
try:
return StringIO.StringIO(zfile.read(os.path.join(
os.path.basename(head), zipname).replace(
os.sep, '/')))
except:
pass
if os.path.isfile(name):
return file(name, mode)