Commits

Evgeny Podjachev committed 2e31702

Clean up.

Comments (0)

Files changed (1)

tests/paths_cache.py

 	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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.