Implement clean for mathjax builder

This commit is contained in:
Kovid Goyal 2019-01-04 22:15:26 +05:30
parent 98a2f53d90
commit d08e0a33e1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -9,9 +9,9 @@ __docformat__ = 'restructuredtext en'
import os, shutil, json import os, shutil, json
from io import BytesIO from io import BytesIO
from zipfile import ZipFile, ZIP_STORED, ZipInfo from zipfile import ZipFile
from hashlib import sha1 from hashlib import sha1
from tempfile import mkdtemp, SpooledTemporaryFile from tempfile import mkdtemp
from setup import Command, download_securely from setup import Command, download_securely
@ -54,12 +54,15 @@ class MathJax(Command):
name = prefix + '/' + os.path.relpath(f, base).replace(os.sep, '/') name = prefix + '/' + os.path.relpath(f, base).replace(os.sep, '/')
self.add_file(f, name) self.add_file(f, name)
def run(self, opts): def clean(self):
self.h = sha1()
self.mathjax_dir = self.j(self.RESOURCES, 'mathjax') self.mathjax_dir = self.j(self.RESOURCES, 'mathjax')
self.mathjax_files = {}
if os.path.exists(self.mathjax_dir): if os.path.exists(self.mathjax_dir):
shutil.rmtree(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) os.mkdir(self.mathjax_dir)
tdir = mkdtemp('calibre-mathjax-build') tdir = mkdtemp('calibre-mathjax-build')
try: try: