Fix regression that was causing metadata to not be properly restored from books that were saved to disk

This commit is contained in:
Kovid Goyal 2008-05-02 13:18:46 -07:00
parent 790abb0b2f
commit 4564cd4c95
3 changed files with 5 additions and 12 deletions

View File

@ -383,11 +383,8 @@ class OPF(MetaInformation):
return ans
def get_series(self):
xm = self.soup.package.metadata.find('x-metadata')
if not xm:
return None
s = xm.find('series')
if s:
s = self.soup.package.metadata.find('series')
if s is not None:
return str(s.string).strip()
return None
@ -397,10 +394,7 @@ class OPF(MetaInformation):
self._set_metadata_element('series', val, type='x-metadata')
def get_series_index(self):
xm = self.soup.package.metadata.find('x-metadata')
if not xm:
return None
s = xm.find('series-index')
s = self.soup.package.metadata.find('series-index')
if s:
try:
return int(str(s.string).strip())
@ -623,7 +617,6 @@ def main(args=sys.argv):
mi.category = opts.category.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
if opts.comment is not None:
mi.comments = opts.comment.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
print mi
mo = OPFCreator(os.getcwd(), mi)
mo.render(open(args[1], 'wb'))
return 0

View File

@ -1404,7 +1404,7 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
cpath = os.path.join(base, cname)
open(cpath, 'wb').write(cover)
mi.cover = cname
f = open(os.path.join(base, name+'.opf'), 'wb')
f = open(os.path.join(base, sanitize_file_name(name)+'.opf'), 'wb')
mi.render(f)
f.close()