- zf = ZipFile(os.path.join(path, archive), 'r')
- infile = zf.open(filename)
+ global _compiled_format
+ _do_compile_format()
+ if _compiled_format[-1] in ('\0', '\\', '/'):
+ raise ValueError('Bad format: "%s"' % _compiled_format)
+ bdict = {}
+ bdict['author'] = book.authors[0].fullname
+ bdict['extension'] = book.extension.name
+ bdict['file'] = book.file
+ genre = book.genres[0]
+ bdict['gname'] = genre.name
+ bdict['gtitle'] = genre.title
+ bdict['language'] = book.language.name
+ bdict['ser_no'] = book.ser_no or 0
+ bdict['series'] = book.series
+ bdict['title'] = book.title
+ if '%(extension)s' not in _compiled_format:
+ _compiled_format += '.%(extension)s'
+ filename = _compiled_format % bdict
+ try:
+ os.makedirs(os.path.dirname(filename))
+ except OSError:
+ pass # Already exists
+ zf = ZipFile(os.path.join(path, book.archive), 'r')
+ infile = zf.open('%s.%s' % (book.file, book.extension.name))