Adding folders now follows Windows ordering
As per issue #11. Was causing problems adding folders numbered 1...999 rather than 001...999.
This commit is contained in:
parent
a71ff52e22
commit
90ab946498
@ -24,6 +24,15 @@ from options import DialogOptions
|
|||||||
from convert import DialogConvert
|
from convert import DialogConvert
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
|
digits = re.compile(r'(\d+)')
|
||||||
|
def tokenize(filename):
|
||||||
|
return tuple(int(token) if match else token
|
||||||
|
for token, match in
|
||||||
|
((fragment, digits.search(fragment))
|
||||||
|
for fragment in digits.split(filename)))
|
||||||
|
|
||||||
|
|
||||||
class Book(object):
|
class Book(object):
|
||||||
DefaultDevice = 'Kindle 4'
|
DefaultDevice = 'Kindle 4'
|
||||||
DefaultOutputFormat = 'Images & CBZ'
|
DefaultOutputFormat = 'Images & CBZ'
|
||||||
@ -369,11 +378,14 @@ class MainWindowBook(QtGui.QMainWindow):
|
|||||||
filenames = []
|
filenames = []
|
||||||
|
|
||||||
for directory in directories:
|
for directory in directories:
|
||||||
for root, subdirs, subfiles in os.walk(unicode(directory)):
|
directory = unicode(directory)
|
||||||
for filename in subfiles:
|
for item in sorted(os.listdir(directory), key=tokenize):
|
||||||
path = os.path.join(root, filename)
|
item = unicode(item)
|
||||||
if self.isImageFile(path):
|
path = os.path.join(directory, item)
|
||||||
filenames.append(path)
|
if self.isImageFile(path):
|
||||||
|
filenames.append(path)
|
||||||
|
elif os.path.isdir:
|
||||||
|
self.addImageDirs([path])
|
||||||
|
|
||||||
self.addImageFiles(filenames)
|
self.addImageFiles(filenames)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user