def convert(self, oeb_book, output_path, input_plugin, opts, log): close = False if not hasattr(output_path, 'write'): close = True if not os.path.exists(os.path.dirname(output_path)) and os.path.dirname(output_path): os.makedirs(os.path.dirname(output_path)) out_stream = lopen(output_path, 'wb') else: out_stream = output_path Writer = get_writer(opts.format) if Writer is None: raise PDBError('No writer available for format %s.' % format) setattr(opts, 'max_line_length', 0) setattr(opts, 'force_max_line_length', False) writer = Writer(opts, log) out_stream.seek(0) out_stream.truncate() writer.write_content(oeb_book, out_stream, oeb_book.metadata) if close: out_stream.close()
def convert(self, oeb_book, output_path, input_plugin, opts, log): close = False if not hasattr(output_path, 'write'): close = True if not os.path.exists(os.path.dirname(output_path)) and os.path.dirname(output_path) != '': os.makedirs(os.path.dirname(output_path)) out_stream = open(output_path, 'wb') else: out_stream = output_path Writer = get_writer(opts.format) if Writer is None: raise PDBError('No writer available for format %s.' % format) setattr(opts, 'max_line_length', 0) setattr(opts, 'force_max_line_length', False) writer = Writer(opts, log) out_stream.seek(0) out_stream.truncate() writer.write_content(oeb_book, out_stream, oeb_book.metadata) if close: out_stream.close()