Core function to search the indexes and return data

def search(self, searchString, category="", math=False, game=False, searchFiles=False, extension=""):
		"""Core function to search the indexes and return data"""
		data = []
		nameData = {}
		fileData = {}
		
		#Search the name index
		if searchFiles:
			fileData = self.searchNamesIndex(self.fileIndex, fileData, searchString, category, math, game, extension, searchFiles)
		else:
			nameData = self.searchNamesIndex(self.nameIndex, nameData, searchString)
			
		#Now search the file index
		if searchFiles:
			nameData, fileData = self.searchFilesIndex(fileData, nameData, self.nameIndex, searchString)
		else:
			fileData, nameData = self.searchFilesIndex(nameData, fileData, self.fileIndex, searchString, category, math, game, extension)
			
		# Bail out if we failed to do either of those things.
		if fileData is None or nameData is None:
			self.repo.printd("Error: failed to load one or more of the index files for this repo. Exiting.")
			self.repo.printd("Please run 'calcpkg update' and retry this command.")
			sys.exit(1)
			
		# Prepare output to parse
		space = 0
		longestFile = len("File Name:")
		for key, value in nameData.iteritems():
			fileValue = fileData[key]
			data.append([fileValue, value])
			if not fileValue is None:
				folder = fileValue.rpartition("/")[0]
				if space < len(folder):
					space = len(folder)
			if not value is None:
				if longestFile < len(value):
					longestFile = len(value)

		#Print output
		space += 5
		if len(data) != 0:
			self.repo.printd("Results for repo: " + self.repo.name)
			self.repo.printd(structureOutput("File Category:", "File Name:", False, False, space))
			self.repo.printd("-" * (space + longestFile))
		else:
			self.repo.printd("No packages found")
		returnData = []
		for datum in data:
			try:
				self.repo.printd(structureOutput(datum[0], datum[1], searchFiles, True, space))
				returnData.append([datum[0], datum[1]])
			except:
				pass
		self.repo.printd(" ")
		
		#Return data
		return returnData