mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
media.check() takes a list of files for ankiweb integration
This commit is contained in:
parent
01b297babc
commit
357e5e7036
1 changed files with 11 additions and 10 deletions
|
@ -122,11 +122,9 @@ If the same name exists, compare checksums."""
|
||||||
# Rebuilding DB
|
# Rebuilding DB
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def check(self, delete=False):
|
def check(self, delete=False, local=None):
|
||||||
"Return (missingFiles, unusedFiles)."
|
"Return (missingFiles, unusedFiles)."
|
||||||
mdir = self.dir()
|
mdir = self.dir()
|
||||||
if not mdir:
|
|
||||||
return (0, 0)
|
|
||||||
# generate card q/a and look through all references
|
# generate card q/a and look through all references
|
||||||
normrefs = {}
|
normrefs = {}
|
||||||
def norm(s):
|
def norm(s):
|
||||||
|
@ -137,13 +135,16 @@ If the same name exists, compare checksums."""
|
||||||
normrefs[norm(f)] = True
|
normrefs[norm(f)] = True
|
||||||
# loop through directory and find unused & missing media
|
# loop through directory and find unused & missing media
|
||||||
unused = []
|
unused = []
|
||||||
for file in os.listdir(mdir):
|
if local is None:
|
||||||
if file.startswith("latex-"):
|
files = os.listdir(mdir)
|
||||||
continue
|
else:
|
||||||
path = os.path.join(mdir, file)
|
files = local
|
||||||
if not os.path.isfile(path):
|
for file in files:
|
||||||
# ignore directories
|
if not local:
|
||||||
continue
|
path = os.path.join(mdir, file)
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
# ignore directories
|
||||||
|
continue
|
||||||
nfile = norm(file)
|
nfile = norm(file)
|
||||||
if nfile not in normrefs:
|
if nfile not in normrefs:
|
||||||
unused.append(file)
|
unused.append(file)
|
||||||
|
|
Loading…
Reference in a new issue