This commit is contained in:
Kovid Goyal 2008-06-14 12:22:43 -07:00
parent 3ad9cc9ef2
commit ad3581aaaf
2 changed files with 10 additions and 6 deletions

View File

@ -25,7 +25,7 @@ def sanitize_file_name(name, substitute='_'):
''' '''
Sanitize the filename `name`. All invalid characters are replaced by `substitute`. Sanitize the filename `name`. All invalid characters are replaced by `substitute`.
The set of invalid characters is the union of the invalid characters in Windows, The set of invalid characters is the union of the invalid characters in Windows,
OS X and Linux. OS X and Linux. Also removes leading an trailing whitespace.
**WARNING:** This function also replaces path separators, so only pass file names **WARNING:** This function also replaces path separators, so only pass file names
and not full paths to it. and not full paths to it.
*NOTE:* This function always returns byte strings, not unicode objects. The byte strings *NOTE:* This function always returns byte strings, not unicode objects. The byte strings
@ -33,7 +33,8 @@ def sanitize_file_name(name, substitute='_'):
''' '''
if isinstance(name, unicode): if isinstance(name, unicode):
name = name.encode(filesystem_encoding, 'ignore') name = name.encode(filesystem_encoding, 'ignore')
return _filename_sanitize.sub(substitute, name) one = _filename_sanitize.sub(substitute, name)
return re.sub(r'\s', ' ', one).strip()
class CoverCache(QThread): class CoverCache(QThread):
@ -479,11 +480,13 @@ class LibraryDatabase2(LibraryDatabase):
def migrate_old(self, db, progress): def migrate_old(self, db, progress):
header = _(u'<p>Migrating old database to ebook library in %s<br><center>')%self.library_path header = _(u'<p>Migrating old database to ebook library in %s<br><center>')%self.library_path
progress.setValue(0)
progress.setLabelText(header)
QCoreApplication.processEvents()
db.conn.row_factory = lambda cursor, row : tuple(row) db.conn.row_factory = lambda cursor, row : tuple(row)
books = db.conn.execute('SELECT id, title, sort, timestamp, uri, series_index, author_sort, isbn FROM books ORDER BY id ASC').fetchall() books = db.conn.execute('SELECT id, title, sort, timestamp, uri, series_index, author_sort, isbn FROM books ORDER BY id ASC').fetchall()
progress.setRange(0, len(books)) progress.setRange(0, len(books))
progress.setValue(0)
progress.setLabelText(header)
for book in books: for book in books:
self.conn.execute('INSERT INTO books(id, title, sort, timestamp, uri, series_index, author_sort, isbn) VALUES(?, ?, ?, ?, ?, ?, ?, ?);', book) self.conn.execute('INSERT INTO books(id, title, sort, timestamp, uri, series_index, author_sort, isbn) VALUES(?, ?, ?, ?, ?, ?, ?, ?);', book)

View File

@ -621,6 +621,7 @@ def main():
sys.argv[1:2] = ['py2exe'] sys.argv[1:2] = ['py2exe']
if '--verbose' not in sys.argv: if '--verbose' not in sys.argv:
sys.argv.append('--quiet') #py2exe produces too much output by default sys.argv.append('--quiet') #py2exe produces too much output by default
subprocess.check_call('python setup.py develop', shell=True)
if auto and not os.path.exists('dist\\auto'): if auto and not os.path.exists('dist\\auto'):
print os.path.abspath('dist\\auto'), 'does not exist' print os.path.abspath('dist\\auto'), 'does not exist'
return 1 return 1