<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def searchNamesIndex(self, nameIndex, nameData, searchString, category="", math=False, game=False, extension="", searchFiles=False):
 		"""Search the names index for a string and returns the namedata"""

		nameData = {}
		try:
			nameFile = open(nameIndex, 'rt')
		except IOError:
			self.repo.printd("Error: Unable to read index file " + self.fileIndex)
			return None
			
		count = 1
		for line in nameFile:
			count += 1
			if searchString.lower() in line.lower():
				#Extension argument
				if extension in line:
					nameData[count] = line[:len(line) - 1]
				else:
					nameData[count] = None
				#category arg
				if category in line and extension in line:
					nameData[count] = line[:len(line) - 1]
				else:
					nameData[count] = None
				#Both game and math
				if (game and math):
					if ("/games/" in line or "/math/" in line or "/science" in line):
						nameData[count] = line[:len(line) - 1]
					else:
						nameData[count] = None
				#Game option switch
				elif game:
					if "/games/" in line:
						nameData[count] = line[:len(line) - 1]
					else:
						nameData[count] = None
				#Math option switch
				elif math:
					if ("/math/" in line or "/science/" in line):
						nameData[count] = line[:len(line) - 1]
					else:
						nameData[count] = None

		#Close the name index and return
		nameFile.close()
		return nameData