From d08e0a33e1dcefad0ea558c42d3323926663c651 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Jan 2019 22:15:26 +0530 Subject: [PATCH] Implement clean for mathjax builder --- setup/mathjax.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/setup/mathjax.py b/setup/mathjax.py index 5a49f07ce9..561d161433 100644 --- a/setup/mathjax.py +++ b/setup/mathjax.py @@ -9,9 +9,9 @@ __docformat__ = 'restructuredtext en' import os, shutil, json from io import BytesIO -from zipfile import ZipFile, ZIP_STORED, ZipInfo +from zipfile import ZipFile from hashlib import sha1 -from tempfile import mkdtemp, SpooledTemporaryFile +from tempfile import mkdtemp from setup import Command, download_securely @@ -54,12 +54,15 @@ class MathJax(Command): name = prefix + '/' + os.path.relpath(f, base).replace(os.sep, '/') self.add_file(f, name) - def run(self, opts): - self.h = sha1() + def clean(self): self.mathjax_dir = self.j(self.RESOURCES, 'mathjax') - self.mathjax_files = {} if os.path.exists(self.mathjax_dir): shutil.rmtree(self.mathjax_dir) + + def run(self, opts): + self.h = sha1() + self.mathjax_files = {} + self.clean() os.mkdir(self.mathjax_dir) tdir = mkdtemp('calibre-mathjax-build') try: