diff options
author | Paweł Jastrzębski <pawelj@iosphe.re> | 2017-10-13 11:56:51 +0200 |
---|---|---|
committer | Paweł Jastrzębski <pawelj@iosphe.re> | 2017-10-13 11:56:51 +0200 |
commit | 658d2f328192b82da5cda9f66217eaa003dd9ea5 (patch) | |
tree | e0fc1798a66ecdcc9f0502d41fdc815b886112c0 /kindlecomicconverter | |
parent | Fixed HQ mode upscaling (close #248) (diff) | |
download | kcc-658d2f328192b82da5cda9f66217eaa003dd9ea5.tar.gz kcc-658d2f328192b82da5cda9f66217eaa003dd9ea5.tar.bz2 kcc-658d2f328192b82da5cda9f66217eaa003dd9ea5.zip |
Fixed directory sorting (close #235)
Diffstat (limited to 'kindlecomicconverter')
-rwxr-xr-x | kindlecomicconverter/comic2ebook.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 459695d..e27d5e6 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -699,7 +699,7 @@ def sanitizeTree(filetree): for root, dirs, files in os.walk(filetree, False): for name in files: splitname = os.path.splitext(name) - slugified = slugify(splitname[0]) + slugified = slugify(splitname[0], False) while os.path.exists(os.path.join(root, slugified + splitname[1])) and splitname[0].upper()\ != slugified.upper(): slugified += "A" @@ -709,7 +709,7 @@ def sanitizeTree(filetree): os.replace(key, newKey) for name in dirs: tmpName = name - slugified = slugify(name) + slugified = slugify(name, True) while os.path.exists(os.path.join(root, slugified)) and name.upper() != slugified.upper(): slugified += "A" chapterNames[slugified] = tmpName @@ -856,8 +856,11 @@ def createNewTome(): return tomePath, tomePathRoot -def slugify(value): - value = slugifyExt(value) +def slugify(value, isDir): + if isDir: + value = slugifyExt(value, regex_pattern=r'[^-a-z0-9_\.]+') + else: + value = slugifyExt(value) value = sub(r'0*([0-9]{4,})', r'\1', sub(r'([0-9]+)', r'0000\1', value, count=2)) return value |