Fix bug in OEBWriter that could cause writing out of resources in subdirectories with URL unsafe names to fail

This commit is contained in:
Kovid Goyal 2010-01-16 14:21:54 -07:00
parent 1318348d57
commit fd70e44ecb
3 changed files with 9 additions and 8 deletions

View File

@ -421,16 +421,16 @@ class DirContainer(object):
return f.read()
def write(self, path, data):
path = os.path.join(self.rootdir, path)
path = os.path.join(self.rootdir, urlunquote(path))
dir = os.path.dirname(path)
if not os.path.isdir(dir):
os.makedirs(dir)
with open(urlunquote(path), 'wb') as f:
with open(path, 'wb') as f:
return f.write(data)
def exists(self, path):
path = os.path.join(self.rootdir, path)
return os.path.isfile(urlunquote(path))
path = os.path.join(self.rootdir, urlunquote(path))
return os.path.isfile(path)
def namelist(self):
names = []

View File

@ -62,6 +62,7 @@ class OEBWriter(object):
output = DirContainer(path, oeb.log)
for item in oeb.manifest.values():
output.write(item.href, str(item))
if version == 1:
metadata = oeb.to_opf1()
elif version == 2:

View File

@ -2245,7 +2245,7 @@ msgstr ""
"kommando ...\n"
"\n"
"Kommandot kan vara något av följande:\n"
"[%% kommandon]\n"
"[%%commands]\n"
"\n"
"Använd %prog kommando --help för att få mer information om ett visst "
"kommando\n"
@ -6213,7 +6213,7 @@ msgstr "<p> För hjälp se: <a href=\"%s\"> Användarhandbok </ a> <br>"
#: /home/kovid/work/calibre/src/calibre/gui2/ui.py:224
msgid "<b>%s</b>: %s by <b>Kovid Goyal %%(version)s</b><br>%%(device)s</p>"
msgstr ""
"<b>%s </ b>:%s av <b> Kovid Goyal%% (version) s </ b> <br>%% (enhet) s </ p>"
"<b>%s </ b>:%s av <b> Kovid Goyal %%(version)s </ b> <br>%%(device)s </ p>"
#: /home/kovid/work/calibre/src/calibre/gui2/ui.py:247
msgid "Edit metadata individually"
@ -7828,7 +7828,7 @@ msgid ""
msgstr ""
"%%prog kommando [alternativ] [argument]\n"
"\n"
"%% PROG är kommandoradsgränssnitt till calibres bokdatabasen.\n"
"%%prog är kommandoradsgränssnitt till calibres bokdatabasen.\n"
"\n"
"kommando är en av:\n"
" %s\n"