packager change
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 25 Jan 2012 10:50:25 +0000 (11:50 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 25 Jan 2012 10:50:25 +0000 (11:50 +0100)
librarian/packagers.py
scripts/book2partner

index 36a7b60..ddfd7c8 100644 (file)
@@ -75,7 +75,7 @@ class PrestigioPdfPackager(PdfPackager):
     flags = ('less-advertising',)
 
 
     flags = ('less-advertising',)
 
 
-class VirtualoEpubPackager(Packager):
+class VirtualoPackager(Packager):
     @staticmethod
     def utf_trunc(text, limit):
         """ truncates text to at most `limit' bytes in utf-8 """
     @staticmethod
     def utf_trunc(text, limit):
         """ truncates text to at most `limit' bytes in utf-8 """
@@ -133,9 +133,16 @@ class VirtualoEpubPackager(Packager):
                 cover.VirtualoCover(info).save(os.path.join(outfile_dir, slug+'.jpg'))
                 outfile = os.path.join(outfile_dir, '1.epub')
                 outfile_sample = os.path.join(outfile_dir, '1.sample.epub')
                 cover.VirtualoCover(info).save(os.path.join(outfile_dir, slug+'.jpg'))
                 outfile = os.path.join(outfile_dir, '1.epub')
                 outfile_sample = os.path.join(outfile_dir, '1.sample.epub')
-                doc.save_output_file(epub.transform(doc),
+                doc.save_output_file(doc.as_epub(),
                         output_path=outfile)
                         output_path=outfile)
-                doc.save_output_file(epub.transform(doc, sample=25), 
+                doc.save_output_file(doc.as_epub(doc, sample=25), 
+                        output_path=outfile_sample)
+                outfile = os.path.join(outfile_dir, '1.mobi')
+                outfile_sample = os.path.join(outfile_dir, '1.sample.mobi')
+                doc.save_output_file(doc.as_mobi(cover=cover.VirtualoCover),
+                        output_path=outfile)
+                doc.save_output_file(
+                        doc.as_mobi(doc, cover=cover.VirtualoCover, sample=25), 
                         output_path=outfile_sample)
         except ParseError, e:
             print '%(file)s:%(name)s:%(message)s' % {
                         output_path=outfile_sample)
         except ParseError, e:
             print '%(file)s:%(name)s:%(message)s' % {
index 0488273..4b84c2f 100755 (executable)
@@ -46,7 +46,7 @@ if __name__ == '__main__':
     if options.gandalf_pdf:
         packagers.GandalfPdfPackager.prepare(input_filenames, options.output_dir, options.verbose)
     if options.virtualo:
     if options.gandalf_pdf:
         packagers.GandalfPdfPackager.prepare(input_filenames, options.output_dir, options.verbose)
     if options.virtualo:
-        packagers.VirtualoEpubPackager.prepare(input_filenames, options.output_dir, options.verbose)
+        packagers.VirtualoPackager.prepare(input_filenames, options.output_dir, options.verbose)
     if options.prestigio:
         packagers.PrestigioEpubPackager.prepare(input_filenames, options.output_dir, options.verbose)
     if options.prestigio_pdf:
     if options.prestigio:
         packagers.PrestigioEpubPackager.prepare(input_filenames, options.output_dir, options.verbose)
     if options.prestigio_pdf: