1. Evgeny Podjachev
  2. FastFileSelector

Commits

Evgeny Podjachev  committed 2e31702

Clean up.

  • Participants
  • Parent commits 3a19220
  • Branches master

Comments (0)

Files changed (1)

File tests/paths_cache.py

View file
  • Ignore whitespace
 	def __init__(self, pathToCache, caseSensitivePaths):
 		self.caseSensitivePaths = caseSensitivePaths
 
+		if self.caseSensitivePaths:
+			self.caseSelectAddon = ''
+		else:
+			self.caseSelectAddon = 'COLLATE NOCASE'
+
 		# Check if database file exists and creates all needed paths.
 		createTable = False
 		if not os.path.exists(pathToCache):
 		if self.conn == None:
 			return []
 
-		if self.caseSensitivePaths:
-			addon = ''
-		else:
-			addon = 'COLLATE NOCASE'
-
 		c = self.conn.cursor()
 
 		# get parent id
-		c.execute('SELECT id FROM roots WHERE path = "%s" %s' % (path, addon))
+		c.execute('SELECT id FROM roots WHERE path = "%s" %s' % (path, self.caseSelectAddon))
 		res = c.fetchone()
 		if res == None:
 			c.close()
 		if self.conn == None:
 			return
 
-		if self.caseSensitivePaths:
-			addon = ''
-		else:
-			addon = 'COLLATE NOCASE'
-
 		c = self.conn.cursor()
 
 		# root must have separator at the end
 			root += os.pathsep
 
 		# get root id
-		c.execute('SELECT id FROM roots WHERE path = "%s" %s' % (root, addon))
+		c.execute('SELECT id FROM roots WHERE path = "%s" %s' % (root, self.caseSelectAddon))
 
 		res = c.fetchone()
 		if res == None:
 			c.execute("INSERT OR REPLACE INTO roots VALUES(NULL, '%s', %s)" % (root, getModTime(root)))
-			c.execute('SELECT id FROM roots WHERE path = "%s" %s' % (root, addon))
+			c.execute('SELECT id FROM roots WHERE path = "%s" %s' % (root, self.caseSelectAddon))
 			res = c.fetchone()
 			if res == None:
 				return
 		# insert files
 		# TODO: Batch insert
 		for i in paths:
-			c.execute('SELECT id FROM paths WHERE root_id = %s, path = "%s" %s' % (root_id, i[0], addon))
+			c.execute('SELECT id FROM paths WHERE root_id = %s, path = "%s" %s' % (root_id, i[0], self.caseSelectAddon))
 			path_id = c.fetchone()
 			if path_id == None:
 				continue