mirror of
https://github.com/iiab/iiab.git
synced 2025-02-14 20:22:08 +00:00
handle multiple versions of a zim
This commit is contained in:
parent
bb5975648d
commit
39632ce8ab
1 changed files with 14 additions and 9 deletions
|
@ -55,24 +55,29 @@ def main():
|
||||||
content = xsce_zim_path + "/content/"
|
content = xsce_zim_path + "/content/"
|
||||||
index = xsce_zim_path + "/index/"
|
index = xsce_zim_path + "/index/"
|
||||||
|
|
||||||
for filename in os.listdir(content):
|
flist = os.listdir(content)
|
||||||
|
flist.sort()
|
||||||
|
for filename in flist:
|
||||||
zimpos = filename.find(".zim")
|
zimpos = filename.find(".zim")
|
||||||
if zimpos != -1:
|
if zimpos != -1:
|
||||||
filename = filename[:zimpos]
|
filename = filename[:zimpos]
|
||||||
if filename not in files_processed:
|
if filename not in files_processed:
|
||||||
files_processed[filename] = True
|
files_processed[filename] = True
|
||||||
command = kiwix_manage + " " + kiwix_library_xml + " add " + content + filename + ".zim -i " + index + filename + ".zim.idx"
|
command = kiwix_manage + " " + kiwix_library_xml + " add " + content + filename + ".zim -i " + index + filename + ".zim.idx"
|
||||||
|
#command = kiwix_manage + " " + kiwix_library_xml + " add " + content + filename + ".zim"
|
||||||
#print command
|
#print command
|
||||||
args = shlex.split(command)
|
args = shlex.split(command)
|
||||||
outp = subprocess.check_output(args)
|
try:
|
||||||
|
outp = subprocess.check_output(args)
|
||||||
|
|
||||||
# create map of generic zim name to actual, assumes pattern of <name>_<yyyy-mm>
|
# create map of generic zim name to actual, assumes pattern of <name>_<yyyy-mm>
|
||||||
# all current files follow this pattern, but some older ones, no longer in the catalog, do not
|
# all current files follow this pattern, but some older ones, no longer in the catalog, do not
|
||||||
|
ulpos = filename.rfind("_")
|
||||||
ulpos = filename.rfind("_")
|
wiki_name = filename[:ulpos]
|
||||||
wiki_name = filename[:ulpos]
|
zim_versions[wiki_name] = filename # if there are multiples, last should win
|
||||||
|
except: #skip things that don't work
|
||||||
zim_versions[wiki_name] = filename
|
print 'skipping ' + filename
|
||||||
|
pass
|
||||||
|
|
||||||
with open(zim_version_idx, 'w') as fp:
|
with open(zim_version_idx, 'w') as fp:
|
||||||
json.dump(zim_versions, fp)
|
json.dump(zim_versions, fp)
|
||||||
|
|
Loading…
Reference in a new issue