Moved tokenize to utils
Didn't see you had a dedicated file for utility functions, moved tokenize to utils. Added "re" reference to utils.
This commit is contained in:
parent
90ab946498
commit
4d27fda7eb
@ -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):
|
||||
|
@ -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)))
|
||||
|
Loading…
Reference in New Issue
Block a user