mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
make sure exporting ignores subfolders
This commit is contained in:
parent
c3415028b0
commit
94cf132918
1 changed files with 8 additions and 0 deletions
|
@ -199,9 +199,15 @@ class AnkiExporter(Exporter):
|
||||||
flds = row[6]
|
flds = row[6]
|
||||||
mid = row[2]
|
mid = row[2]
|
||||||
for file in self.src.media.filesInStr(mid, flds):
|
for file in self.src.media.filesInStr(mid, flds):
|
||||||
|
# skip files in subdirs
|
||||||
|
if file != os.path.basename(file):
|
||||||
|
continue
|
||||||
media[file] = True
|
media[file] = True
|
||||||
if self.mediaDir:
|
if self.mediaDir:
|
||||||
for fname in os.listdir(self.mediaDir):
|
for fname in os.listdir(self.mediaDir):
|
||||||
|
path = os.path.join(self.mediaDir, fname)
|
||||||
|
if os.path.isdir(path):
|
||||||
|
continue
|
||||||
if fname.startswith("_"):
|
if fname.startswith("_"):
|
||||||
# Scan all models in mids for reference to fname
|
# Scan all models in mids for reference to fname
|
||||||
for m in self.src.models.all():
|
for m in self.src.models.all():
|
||||||
|
@ -293,6 +299,8 @@ class AnkiPackageExporter(AnkiExporter):
|
||||||
for c, file in enumerate(files):
|
for c, file in enumerate(files):
|
||||||
cStr = str(c)
|
cStr = str(c)
|
||||||
mpath = os.path.join(fdir, file)
|
mpath = os.path.join(fdir, file)
|
||||||
|
if os.path.isdir(mpath):
|
||||||
|
continue
|
||||||
if os.path.exists(mpath):
|
if os.path.exists(mpath):
|
||||||
if re.search('\.svg$', file, re.IGNORECASE):
|
if re.search('\.svg$', file, re.IGNORECASE):
|
||||||
z.write(mpath, cStr, zipfile.ZIP_DEFLATED)
|
z.write(mpath, cStr, zipfile.ZIP_DEFLATED)
|
||||||
|
|
Loading…
Reference in a new issue