IGN:Fix path case insensitivity on windows

This commit is contained in:
Kovid Goyal 2008-09-02 10:05:50 -07:00
parent ac2d8bc12b
commit 0a7f8149b7
5 changed files with 14 additions and 10 deletions

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__appname__ = 'calibre'
__version__ = '0.4.84b5'
__version__ = '0.4.84b6'
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
'''
Various run time constants.
@ -16,7 +16,7 @@ terminal_controller = TerminalController(sys.stdout)
iswindows = 'win32' in sys.platform.lower() or 'win64' in sys.platform.lower()
isosx = 'darwin' in sys.platform.lower()
islinux = not(iswindows or isosx)
isfrozen = hasattr(sys, 'frozen')
isfrozen = hasattr(sys, 'frozen')
try:
preferred_encoding = locale.getpreferredencoding()

View File

@ -1446,7 +1446,7 @@ class HTMLConverter(object, LoggingInterface):
pass
if not self.disable_chapter_detection and \
(self.chapter_attr[0].match(tagname) and \
(self.chapter_attr[1].pattern.lower() == 'none' or \
(self.chapter_attr[1].lower() == 'none' or \
(tag.has_key(self.chapter_attr[1]) and \
self.chapter_attr[2].match(tag[self.chapter_attr[1]])))):
self.log_debug('Detected chapter %s', tagname)

View File

@ -1991,7 +1991,7 @@
cx="343.99899"
rx="8.0010004"
r="36"
style="fill:url(#linearGradient5167);fill-opacity:1"
style="fill-opacity:1"
sodipodi:cx="343.99899"
sodipodi:cy="92"
sodipodi:rx="36"

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

@ -274,6 +274,7 @@ class LibraryDatabase2(LibraryDatabase):
if not os.path.exists(tpath):
os.makedirs(tpath)
spath = os.path.join(self.library_path, *current_path.split('/'))
if current_path and os.path.exists(spath): # Migrate existing files
cdata = self.cover(id, index_is_id=True)
if cdata is not None:
@ -288,11 +289,13 @@ class LibraryDatabase2(LibraryDatabase):
self.conn.execute('UPDATE books SET path=? WHERE id=?', (path, id))
self.conn.commit()
# Delete not needed directories
norm = lambda x : os.path.abspath(os.path.normcase(x))
if current_path and os.path.exists(spath):
shutil.rmtree(spath)
parent = os.path.dirname(spath)
if len(os.listdir(parent)) == 0:
shutil.rmtree(parent)
if norm(spath) != norm(tpath):
shutil.rmtree(spath)
parent = os.path.dirname(spath)
if len(os.listdir(parent)) == 0:
shutil.rmtree(parent)
def cover(self, index, index_is_id=False, as_file=False, as_image=False):
'''
@ -382,7 +385,8 @@ class LibraryDatabase2(LibraryDatabase):
def remove_format(self, index, format, index_is_id=False):
id = index if index_is_id else self.id(index)
path = os.path.join(self.library_path, self.path(id, index_is_id=True))
name = self.conn.execute('SELECT name FROM data WHERE book=? AND format=?', (id, format)).fetchone()[0]
name = self.conn.execute('SELECT name FROM data WHERE book=? AND format=?', (id, format)).fetchone()
name = name[0] if name else False
if name:
ext = ('.' + format.lower()) if format else ''
path = os.path.join(path, name+ext)

View File

@ -102,7 +102,7 @@ def build_osx(shutdown=True):
def build_linux(shutdown=True):
installer = installer_name('tar.bz2')
vm = '/vmware/linux/libprs500-gentoo.vmx'
start_vm(vm, 'linux', (BUILD_SCRIPT%('sudo python setup.py develop', 'python','installer/linux/freeze.py')).replace('rm ', 'sudo rm '))
start_vm(vm, 'linux', (BUILD_SCRIPT%('sudo python setup.py develop', 'python','installer/linux/freeze.py')).replace('rm ', 'sudo rm '), sleep=100)
subprocess.check_call(('scp', 'linux:/tmp/%s'%os.path.basename(installer), 'dist'))
if not os.path.exists(installer):
raise Exception('Failed to build installer '+installer)