IGN:Fix fonts on OSX 10.5 and regression affecting adding formats

This commit is contained in:
Kovid Goyal 2008-09-02 22:21:04 -07:00
parent ce3391ff9a
commit a70ac94b6a
4 changed files with 9 additions and 7 deletions

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
__appname__ = 'calibre' __appname__ = 'calibre'
__version__ = '0.4.84b6' __version__ = '0.4.84b7'
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>" __author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
''' '''
Various run time constants. Various run time constants.

View File

@ -100,7 +100,7 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
old_extensions, new_extensions, paths = set(), set(), {} old_extensions, new_extensions, paths = set(), set(), {}
for row in range(self.formats.count()): for row in range(self.formats.count()):
fmt = self.formats.item(row) fmt = self.formats.item(row)
ext, path = fmt.ext, fmt.path ext, path = fmt.ext.lower(), fmt.path
if 'unknown' in ext.lower(): if 'unknown' in ext.lower():
ext = None ext = None
if path: if path:
@ -109,8 +109,8 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
else: else:
old_extensions.add(ext) old_extensions.add(ext)
for ext in new_extensions: for ext in new_extensions:
self.db.add_format(self.row, ext, open(paths[ext], "rb")) self.db.add_format(self.row, ext, open(paths[ext], 'rb'))
db_extensions = set(self.db.formats(self.row).split(',')) db_extensions = set([f.lower() for f in self.db.formats(self.row).split(',')])
extensions = new_extensions.union(old_extensions) extensions = new_extensions.union(old_extensions)
for ext in db_extensions: for ext in db_extensions:
if ext not in extensions: if ext not in extensions:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python from __future__ import with_statement
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
@ -360,7 +360,9 @@ class LibraryDatabase2(LibraryDatabase):
self.conn.execute('DELETE FROM data WHERE book=? AND format=?', (id, format)) self.conn.execute('DELETE FROM data WHERE book=? AND format=?', (id, format))
name = self.construct_file_name(id) name = self.construct_file_name(id)
ext = ('.' + format.lower()) if format else '' ext = ('.' + format.lower()) if format else ''
shutil.copyfileobj(stream, open(os.path.join(path, name+ext), 'wb')) dest = os.path.join(path, name+ext)
with open(dest, 'wb') as f:
shutil.copyfileobj(stream, f)
stream.seek(0, 2) stream.seek(0, 2)
size=stream.tell() size=stream.tell()
self.conn.execute('INSERT INTO data (book,format,uncompressed_size,name) VALUES (?,?,?,?)', self.conn.execute('INSERT INTO data (book,format,uncompressed_size,name) VALUES (?,?,?,?)',

View File

@ -151,7 +151,7 @@ class FontScanner(Thread):
def run(self): def run(self):
# Initialize the fontconfig library. This has to be done manually # Initialize the fontconfig library. This has to be done manually
# for the OS X bundle as it may have its own private fontconfig. # for the OS X bundle as it may have its own private fontconfig.
if getattr(sys, 'frameworks_dir', False) and not os.path.exists('/usr/X11/lib/libfontconfig.1.dylib'): if getattr(sys, 'frameworks_dir', False):# and not os.path.exists('/usr/X11/lib/libfontconfig.1.dylib'):
config_dir = os.path.join(os.path.dirname(getattr(sys, 'frameworks_dir')), 'Resources', 'fonts') config_dir = os.path.join(os.path.dirname(getattr(sys, 'frameworks_dir')), 'Resources', 'fonts')
if isinstance(config_dir, unicode): if isinstance(config_dir, unicode):
config_dir = config_dir.encode(sys.getfilesystemencoding()) config_dir = config_dir.encode(sys.getfilesystemencoding())