diff --git a/mangle/book.py b/mangle/book.py index 633de50..00dd44e 100644 --- a/mangle/book.py +++ b/mangle/book.py @@ -24,15 +24,6 @@ from options import DialogOptions 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): DefaultDevice = 'Kindle 4' DefaultOutputFormat = 'Images & CBZ' @@ -379,7 +370,7 @@ class MainWindowBook(QtGui.QMainWindow): for directory in directories: directory = unicode(directory) - for item in sorted(os.listdir(directory), key=tokenize): + for item in sorted(os.listdir(directory), key=util.tokenize): item = unicode(item) path = os.path.join(directory, item) if self.isImageFile(path): diff --git a/mangle/util.py b/mangle/util.py index 6e39dc6..5b84855 100644 --- a/mangle/util.py +++ b/mangle/util.py @@ -15,8 +15,17 @@ import os.path +import re def buildResPath(relative): directory = os.path.dirname(__file__) return os.path.join(directory, relative) + + +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)))