[LyX/master] ePub: don't use glob.
Thibaut Cuvelier
tcuvelier at lyx.org
Sun Feb 7 05:29:57 UTC 2021
commit 3e745fabbefb44ed86cbaf9af23a0776f0adb620
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Sun Feb 7 06:32:15 2021 +0100
ePub: don't use glob.
Recursivity requires Python 3.5+.
---
lib/scripts/docbook2epub.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/scripts/docbook2epub.py b/lib/scripts/docbook2epub.py
index e60a9d4..8331f61 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)
More information about the lyx-cvs
mailing list