+ has_daisy_file.boolean = True
+
+ def build_pdf(self):
+ """ (Re)builds the pdf file.
+
+ """
+ from librarian import pdf
+ from tempfile import NamedTemporaryFile
+ import os
+
+ try:
+ pdf_file = NamedTemporaryFile(delete=False)
+ pdf.transform(ORMDocProvider(self),
+ file_path=str(self.xml_file.path),
+ output_file=pdf_file,
+ )
+
+ self.pdf_file.save('%s.pdf' % self.slug, File(open(pdf_file.name)))
+ finally:
+ unlink(pdf_file.name)
+
+ # remove zip with all pdf files
+ remove_zip(settings.ALL_PDF_ZIP)
+
+ def build_mobi(self):
+ """ (Re)builds the MOBI file.
+
+ """
+ from librarian import mobi
+ from tempfile import NamedTemporaryFile
+ import os
+
+ try:
+ mobi_file = NamedTemporaryFile(suffix='.mobi', delete=False)
+ mobi.transform(ORMDocProvider(self), verbose=1,
+ file_path=str(self.xml_file.path),
+ output_file=mobi_file.name,
+ )
+
+ self.mobi_file.save('%s.mobi' % self.slug, File(open(mobi_file.name)))
+ finally:
+ unlink(mobi_file.name)
+
+ # remove zip with all mobi files
+ remove_zip(settings.ALL_MOBI_ZIP)
+