def check_tool(self, input, tooldir=None, funs=None):
		"load a waf tool"

		tools = Utils.to_list(input)
		if tooldir: tooldir = Utils.to_list(tooldir)
		for tool in tools:
			tool = tool.replace('++', 'xx')
			if tool == 'java': tool = 'javaw'
			if tool.lower() == 'unittest': tool = 'unittestw'
			# avoid loading the same tool more than once with the same functions
			# used by composite projects

			mag = (tool, id(self.env), funs)
			if mag in self.tool_cache:
				continue
			self.tool_cache.append(mag)

			if not tooldir:
				# check if the tool exists in the Tools or 3rdparty folders
				_Tools = Options.tooldir[0]
				_3rdparty = os.sep.join((_Tools, '..', '3rdparty'))
				for d in (_Tools, _3rdparty):
					lst = os.listdir(d)
					if tool + '.py' in lst:
						break
				else:
					# try to download the tool from the repository then
					for x in Utils.to_list(Options.remote_repo):
						for sub in [WAFVERSION % 'branches/waf-%s/wafadmin/3rdparty', 'trunk/wafadmin/3rdparty']:
							url = '/'.join((x, sub, tool + '.py'))
							try:
								web = urlopen(url)
								if web.getcode() != 200:
									continue
							except Exception, e:
								# on python3 urlopen throws an exception
								continue
							else:
								try:
									loc = open(_3rdparty + os.sep + tool + '.py', 'wb')
									loc.write(web.read())
									web.close()
								finally:
									loc.close()
								Logs.warn('downloaded %s from %s' % (tool, url))
						else:
								break

			module = Utils.load_tool(tool, tooldir)

			if funs is not None:
				self.eval_rules(funs)
			else:
				func = getattr(module, 'detect', None)
				if func:
					if type(func) is type(find_file): func(self)
					else: self.eval_rules(func)

			self.tools.append({'tool':tool, 'tooldir':tooldir, 'funs':funs})
dataset/ETHPy150Open appcelerator-archive/poc-nodejs-desktop/Resources/nodejs/builds/linux/node/lib/node/wafadmin/Configure.py/ConfigurationContext.check_tool/swapped operands of `%`