mirror of
https://github.com/ciromattia/kcc
synced 2025-12-18 20:21:48 +00:00
Fixed directory sorting (close #235)
This commit is contained in:
@@ -699,7 +699,7 @@ def sanitizeTree(filetree):
|
|||||||
for root, dirs, files in os.walk(filetree, False):
|
for root, dirs, files in os.walk(filetree, False):
|
||||||
for name in files:
|
for name in files:
|
||||||
splitname = os.path.splitext(name)
|
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()\
|
while os.path.exists(os.path.join(root, slugified + splitname[1])) and splitname[0].upper()\
|
||||||
!= slugified.upper():
|
!= slugified.upper():
|
||||||
slugified += "A"
|
slugified += "A"
|
||||||
@@ -709,7 +709,7 @@ def sanitizeTree(filetree):
|
|||||||
os.replace(key, newKey)
|
os.replace(key, newKey)
|
||||||
for name in dirs:
|
for name in dirs:
|
||||||
tmpName = name
|
tmpName = name
|
||||||
slugified = slugify(name)
|
slugified = slugify(name, True)
|
||||||
while os.path.exists(os.path.join(root, slugified)) and name.upper() != slugified.upper():
|
while os.path.exists(os.path.join(root, slugified)) and name.upper() != slugified.upper():
|
||||||
slugified += "A"
|
slugified += "A"
|
||||||
chapterNames[slugified] = tmpName
|
chapterNames[slugified] = tmpName
|
||||||
@@ -856,7 +856,10 @@ def createNewTome():
|
|||||||
return tomePath, tomePathRoot
|
return tomePath, tomePathRoot
|
||||||
|
|
||||||
|
|
||||||
def slugify(value):
|
def slugify(value, isDir):
|
||||||
|
if isDir:
|
||||||
|
value = slugifyExt(value, regex_pattern=r'[^-a-z0-9_\.]+')
|
||||||
|
else:
|
||||||
value = slugifyExt(value)
|
value = slugifyExt(value)
|
||||||
value = sub(r'0*([0-9]{4,})', r'\1', sub(r'([0-9]+)', r'0000\1', value, count=2))
|
value = sub(r'0*([0-9]{4,})', r'\1', sub(r'([0-9]+)', r'0000\1', value, count=2))
|
||||||
return value
|
return value
|
||||||
|
|||||||
Reference in New Issue
Block a user