mirror of
https://github.com/ciromattia/kcc
synced 2025-12-21 21:51:52 +00:00
"Natural sorting" for image files (closes #18)
This commit is contained in:
@@ -274,7 +274,9 @@ def genEpubStruct(path):
|
|||||||
copyfile(os.path.join(filelist[-1][0], filelist[-1][1]), cover)
|
copyfile(os.path.join(filelist[-1][0], filelist[-1][1]), cover)
|
||||||
buildNCX(path, options.title, chapterlist)
|
buildNCX(path, options.title, chapterlist)
|
||||||
# ensure we're sorting files alphabetically
|
# ensure we're sorting files alphabetically
|
||||||
filelist = sorted(filelist, key=lambda name: (name[0].lower(), name[1].lower()))
|
convert = lambda text: int(text) if text.isdigit() else text
|
||||||
|
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
|
||||||
|
filelist.sort(key=lambda name: (alphanum_key(name[0].lower()), alphanum_key(name[1].lower())))
|
||||||
buildOPF(options.profile, path, options.title, filelist, cover, options.righttoleft)
|
buildOPF(options.profile, path, options.title, filelist, cover, options.righttoleft)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user