X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e4ffa9f5172b88a5a49ed832634105dd65b9727f..7ba738ac11aeffafb78612d78360972997a21df0:/librarian/weasy.py diff --git a/librarian/weasy.py b/librarian/weasy.py index d2cd7e4..c924a8e 100644 --- a/librarian/weasy.py +++ b/librarian/weasy.py @@ -623,11 +623,12 @@ class EduModuleWeasyFormat(Format): class MaterialNotFound(BaseException): pass - def __init__(self, wldoc, media_root='', **kwargs): + def __init__(self, wldoc, media_root='', save_html_to=None, **kwargs): super(EduModuleWeasyFormat, self).__init__(wldoc, **kwargs) self.media_root = media_root self.materials_by_slug = None self.attachments = {} + self.save_html_to = save_html_to def get_html(self): self.attachments = {} @@ -656,6 +657,10 @@ class EduModuleWeasyFormat(Format): def get_pdf(self): temp = self.get_weasy_dir() + if self.save_html_to: + save_path = os.path.join(self.save_html_to, 'weasy-html') + shutil.rmtree(save_path, ignore_errors=True) + shutil.copytree(temp, save_path) html_path = os.path.join(temp, 'doc.html') pdf_path = os.path.join(temp, 'doc.pdf') try: