From 3e745fabbefb44ed86cbaf9af23a0776f0adb620 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 7 Feb 2021 06:32:15 +0100 Subject: [PATCH] ePub: don't use glob. Recursivity requires Python 3.5+. --- lib/scripts/docbook2epub.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/scripts/docbook2epub.py b/lib/scripts/docbook2epub.py index e60a9d482c..8331f616d3 100644 --- a/lib/scripts/docbook2epub.py +++ b/lib/scripts/docbook2epub.py @@ -13,12 +13,12 @@ from __future__ import print_function +# import glob # Not powerful enough before Python 3.5. import os import shutil import sys import tempfile import zipfile -import glob if __name__ == '__main__': if len(sys.argv) != 4: @@ -63,7 +63,9 @@ if __name__ == '__main__': # Create the actual ePub file. with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as zip: - for file in glob.glob(output_dir + '/**/*', recursive=True): + # Python 3.5 brings the `recursive` argument. For older versions, this trick is required... + # for file in glob.glob(output_dir + '/**/*', recursive=True): + for file in [os.path.join(dp, f) for dp, dn, filenames in os.walk(output_dir) for f in filenames]: zip.write(file, os.path.relpath(file, output_dir), compress_type=zipfile.ZIP_STORED) shutil.rmtree(output_dir)