mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge pull request #153 from tim-moody/wip-aug-11
check for existence of index dir when creating library.xml
This commit is contained in:
commit
3be060403d
1 changed files with 15 additions and 7 deletions
|
@ -37,6 +37,7 @@ kiwix_manage = iiab_base_path + "/kiwix/bin/kiwix-manage"
|
||||||
doc_root = get_iiab_env('WWWROOT')
|
doc_root = get_iiab_env('WWWROOT')
|
||||||
zim_version_idx = doc_root + "/common/assets/zim_version_idx.json"
|
zim_version_idx = doc_root + "/common/assets/zim_version_idx.json"
|
||||||
zim_versions = {}
|
zim_versions = {}
|
||||||
|
old_zim_map = {"bad.zim" : "unparseable name"}
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Server routine"""
|
"""Server routine"""
|
||||||
|
@ -64,8 +65,11 @@ def main():
|
||||||
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"
|
zimname = content + filename + ".zim"
|
||||||
#command = kiwix_manage + " " + kiwix_library_xml + " add " + content + filename + ".zim"
|
zimidx = index + filename + ".zim.idx"
|
||||||
|
command = kiwix_manage + " " + kiwix_library_xml + " add " + zimname
|
||||||
|
if os.path.isdir (zimidx): # only declare index if exists (could be embedded)
|
||||||
|
command += " -i " + zimidx
|
||||||
#print command
|
#print command
|
||||||
args = shlex.split(command)
|
args = shlex.split(command)
|
||||||
try:
|
try:
|
||||||
|
@ -74,13 +78,17 @@ def main():
|
||||||
# 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("_")
|
if filename in old_zim_map: # handle old names that don't parse
|
||||||
# but gutenberg don't
|
wiki_name = old_zim_map[filename]
|
||||||
if "gutenberg_" in filename:
|
else:
|
||||||
ulpos = filename[:ulpos].rfind("_")
|
ulpos = filename.rfind("_")
|
||||||
|
# but gutenberg don't - future maybe put in old_zim_map (en and fr, but instance dates may change)
|
||||||
|
if "gutenberg_" in filename:
|
||||||
|
ulpos = filename[:ulpos].rfind("_")
|
||||||
|
wiki_name = filename[:ulpos]
|
||||||
|
|
||||||
wiki_name = filename[:ulpos]
|
|
||||||
zim_versions[wiki_name] = filename # if there are multiples, last should win
|
zim_versions[wiki_name] = filename # if there are multiples, last should win
|
||||||
|
|
||||||
except: #skip things that don't work
|
except: #skip things that don't work
|
||||||
print 'skipping ' + filename
|
print 'skipping ' + filename
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Add table
Reference in a new issue