Index: tools/config.py
===================================================================
--- tools/config.py	(revision 47566347abc1fe7976a15f8b83986005eee06ea6)
+++ tools/config.py	(revision ba8de9c389dfb9668896f59bf2ab23fd720f9f36)
@@ -53,5 +53,5 @@
 	for line in inf:
 		res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
-		if (res):
+		if res:
 			config[res.group(1)] = res.group(2)
 	
@@ -63,8 +63,8 @@
 	ctype = 'cnf'
 	
-	if ((')|' in text) or ('|(' in text)):
+	if (')|' in text) or ('|(' in text):
 		ctype = 'dnf'
 	
-	if (ctype == 'cnf'):
+	if ctype == 'cnf':
 		conds = text.split('&')
 	else:
@@ -72,5 +72,5 @@
 	
 	for cond in conds:
-		if (cond.startswith('(')) and (cond.endswith(')')):
+		if cond.startswith('(') and cond.endswith(')'):
 			cond = cond[1:-1]
 		
@@ -80,8 +80,8 @@
 			return False
 		
-		if (ctype == 'dnf') and (inside):
+		if (ctype == 'dnf') and inside:
 			return True
 	
-	if (ctype == 'cnf'):
+	if ctype == 'cnf':
 		return True
 	return False
@@ -90,5 +90,5 @@
 	"Check for condition"
 	
-	if (ctype == 'cnf'):
+	if ctype == 'cnf':
 		conds = text.split('|')
 	else:
@@ -97,5 +97,5 @@
 	for cond in conds:
 		res = re.match(r'^(.*?)(!?=)(.*)$', cond)
-		if (not res):
+		if not res:
 			raise RuntimeError("Invalid condition: %s" % cond)
 		
@@ -104,5 +104,5 @@
 		condval = res.group(3)
 		
-		if (not condname in config):
+		if not condname in config:
 			varval = ''
 		else:
@@ -111,5 +111,5 @@
 				varval = 'y'
 		
-		if (ctype == 'cnf'):
+		if ctype == 'cnf':
 			if (oper == '=') and (condval == varval):
 				return True
@@ -124,5 +124,5 @@
 				return False
 	
-	if (ctype == 'cnf'):
+	if ctype == 'cnf':
 		return False
 	
@@ -139,9 +139,9 @@
 	for line in inf:
 		
-		if (line.startswith('!')):
+		if line.startswith('!'):
 			# Ask a question
 			res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
 			
-			if (not res):
+			if not res:
 				raise RuntimeError("Weird line: %s" % line)
 			
@@ -155,5 +155,5 @@
 			continue
 		
-		if (line.startswith('@')):
+		if line.startswith('@'):
 			# Add new line into the 'choices' array
 			res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
@@ -165,10 +165,10 @@
 			continue
 		
-		if (line.startswith('%')):
+		if line.startswith('%'):
 			# Name of the option
 			name = line[1:].strip()
 			continue
 		
-		if ((line.startswith('#')) or (line == '\n')):
+		if line.startswith('#') or (line == '\n'):
 			# Comment or empty line
 			continue
@@ -182,5 +182,5 @@
 	"Return '*' if yes, ' ' if no"
 	
-	if (default == 'y'):
+	if default == 'y':
 		return '*'
 	
@@ -200,5 +200,5 @@
 	cnt = 0
 	for key, val in choices:
-		if ((default) and (key == default)):
+		if (default) and (key == default):
 			position = cnt
 		
@@ -208,5 +208,5 @@
 	(button, value) = xtui.choice_window(screen, name, 'Choose value', options, position)
 	
-	if (button == 'cancel'):
+	if button == 'cancel':
 		return None
 	
@@ -227,21 +227,23 @@
 	"Infer and verify configuration values."
 	
-	for varname, vartype, name, choices, cond in rules:
-		if ((cond) and (not check_condition(cond, config, rules))):
+	for rule in rules:
+		varname, vartype, name, choices, cond = rule
+
+		if cond and (not check_condition(cond, config, rules)):
 			continue
 		
-		if (not varname in config):
+		if not varname in config:
 			value = None
 		else:
 			value = config[varname]
 
-		if not rule_value_is_valid((varname, vartype, name, choices, cond), value):
+		if not rule_value_is_valid(rule, value):
 			value = None
 
-		default = rule_get_default((varname, vartype, name, choices, cond))
+		default = rule_get_default(rule)
 		if default != None:
 			config[varname] = default
 
-		if (not varname in config):
+		if not varname in config:
 			return False
 	
@@ -254,15 +256,15 @@
 	default = None
 
-	if (vartype == 'choice'):
+	if vartype == 'choice':
 		# If there is just one option, use it
-		if (len(choices) == 1):
+		if len(choices) == 1:
 			default = choices[0][0]
-	elif (vartype == 'y'):
+	elif vartype == 'y':
 		default = '*'
-	elif (vartype == 'n'):
+	elif vartype == 'n':
 		default = 'n'
-	elif (vartype == 'y/n'):
+	elif vartype == 'y/n':
 		default = 'y'
-	elif (vartype == 'n/y'):
+	elif vartype == 'n/y':
 		default = 'n'
 	else:
@@ -283,18 +285,18 @@
 	option = None
 
-	if (vartype == 'choice'):
+	if vartype == 'choice':
 		# If there is just one option, don't ask
-		if (len(choices) != 1):
+		if len(choices) != 1:
 			if (value == None):
 				option = "?     %s --> " % name
 			else:
 				option = "      %s [%s] --> " % (name, value)
-	elif (vartype == 'y'):
+	elif vartype == 'y':
 		pass
-	elif (vartype == 'n'):
+	elif vartype == 'n':
 		pass
-	elif (vartype == 'y/n'):
+	elif vartype == 'y/n':
 		option = "  <%s> %s " % (yes_no(value), name)
-	elif (vartype == 'n/y'):
+	elif vartype == 'n/y':
 		option ="  <%s> %s " % (yes_no(value), name)
 	else:
@@ -316,17 +318,17 @@
 		return True
 
-	if (vartype == 'choice'):
-		if (not value in [choice[0] for choice in choices]):
-			return False
-	elif (vartype == 'y'):
+	if vartype == 'choice':
+		if not value in [choice[0] for choice in choices]:
+			return False
+	elif vartype == 'y':
 		if value != 'y':
 			return False
-	elif (vartype == 'n'):
+	elif vartype == 'n':
 		if value != 'n':
 			return False
-	elif (vartype == 'y/n'):
+	elif vartype == 'y/n':
 		if not value in ['y', 'n']:
 			return False
-	elif (vartype == 'n/y'):
+	elif vartype == 'n/y':
 		if not value in ['y', 'n']:
 			return False
@@ -350,7 +352,7 @@
 		sys.stderr.write("failed\n")
 	
-	if (len(version) == 3):
+	if len(version) == 3:
 		revision = version[1]
-		if (version[0] != 1):
+		if version[0] != 1:
 			revision += 'M'
 		revision += ' (%s)' % version[2]
@@ -372,8 +374,8 @@
 	
 	for varname, vartype, name, choices, cond in rules:
-		if ((cond) and (not check_condition(cond, config, rules))):
+		if cond and (not check_condition(cond, config, rules)):
 			continue
 		
-		if (not varname in config):
+		if not varname in config:
 			value = ''
 		else:
@@ -384,6 +386,6 @@
 		outmk.write('# %s\n%s = %s\n\n' % (name, varname, value))
 		
-		if ((vartype == "y") or (vartype == "n") or (vartype == "y/n") or (vartype == "n/y")):
-			if (value == "y"):
+		if vartype in ["y", "n", "y/n", "n/y"]:
+			if value == "y":
 				outmc.write('/* %s */\n#define %s\n\n' % (name, varname))
 				defs += ' -D%s' % varname
@@ -392,5 +394,5 @@
 			defs += ' -D%s=%s -D%s_%s' % (varname, value, varname, value)
 	
-	if (revision is not None):
+	if revision is not None:
 		outmk.write('REVISION = %s\n' % revision)
 		outmc.write('#define REVISION %s\n' % revision)
@@ -423,5 +425,5 @@
 		canon = os.path.join(path, fname)
 		
-		if ((os.path.isdir(path)) and (os.path.exists(canon)) and (os.path.isfile(canon))):
+		if os.path.isdir(path) and os.path.exists(canon) and os.path.isfile(canon):
 			subprofile = False
 			
@@ -431,5 +433,5 @@
 				subcanon = os.path.join(subpath, fname)
 				
-				if ((os.path.isdir(subpath)) and (os.path.exists(subcanon)) and (os.path.isfile(subcanon))):
+				if os.path.isdir(subpath) and os.path.exists(subcanon) and os.path.isfile(subcanon):
 					subprofile = True
 					options.append("%s (%s)" % (name, subname))
@@ -437,5 +439,5 @@
 					cnt += 1
 			
-			if (not subprofile):
+			if not subprofile:
 				options.append(name)
 				opt2path[cnt] = (canon, None)
@@ -444,9 +446,9 @@
 	(button, value) = xtui.choice_window(screen, 'Load preconfigured defaults', 'Choose configuration profile', options, None)
 	
-	if (button == 'cancel'):
+	if button == 'cancel':
 		return None
 	
 	read_config(opt2path[value][0], config)
-	if (opt2path[value][1] != None):
+	if opt2path[value][1] != None:
 		read_config(opt2path[value][1], config)
 
@@ -463,5 +465,5 @@
 	
 	# Default mode: only check values and regenerate configuration files
-	if ((len(sys.argv) >= 3) and (sys.argv[2] == 'default')):
+	if (len(sys.argv) >= 3) and (sys.argv[2] == 'default'):
 		if (infer_verify_choices(config, rules)):
 			create_output(MAKEFILE, MACROS, config, rules)
@@ -469,6 +471,6 @@
 	
 	# Check mode: only check configuration
-	if ((len(sys.argv) >= 3) and (sys.argv[2] == 'check')):
-		if (infer_verify_choices(config, rules)):
+	if (len(sys.argv) >= 3) and (sys.argv[2] == 'check'):
+		if infer_verify_choices(config, rules):
 			return 0
 		return 1
@@ -482,5 +484,5 @@
 			# Cancel out all values which have to be deduced
 			for varname, vartype, name, choices, cond in rules:
-				if ((vartype == 'y') and (varname in config) and (config[varname] == '*')):
+				if (vartype == 'y') and (varname in config) and (config[varname] == '*'):
 					config[varname] = None
 			
@@ -494,11 +496,11 @@
 				varname, vartype, name, choices, cond = rule
 				
-				if ((cond) and (not check_condition(cond, config, rules))):
+				if cond and (not check_condition(cond, config, rules)):
 					continue
 				
-				if (varname == selname):
+				if varname == selname:
 					position = cnt
 				
-				if (not varname in config):
+				if not varname in config:
 					value = None
 				else:
@@ -526,8 +528,8 @@
 			(button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
 			
-			if (button == 'cancel'):
+			if button == 'cancel':
 				return 'Configuration canceled'
 			
-			if (button == 'done'):
+			if button == 'done':
 				if (infer_verify_choices(config, rules)):
 					break
@@ -536,5 +538,5 @@
 					continue
 			
-			if (value == 0):
+			if value == 0:
 				load_presets(PRESETS_DIR, MAKEFILE, screen, config)
 				position = 1
@@ -542,18 +544,18 @@
 			
 			position = None
-			if (not value in opt2row):
+			if not value in opt2row:
 				raise RuntimeError("Error selecting value: %s" % value)
 			
 			(selname, seltype, name, choices) = opt2row[value]
 			
-			if (not selname in config):
+			if not selname in config:
 				value = None
 			else:
 				value = config[selname]
 			
-			if (seltype == 'choice'):
+			if seltype == 'choice':
 				config[selname] = subchoice(screen, name, choices, value)
-			elif ((seltype == 'y/n') or (seltype == 'n/y')):
-				if (config[selname] == 'y'):
+			elif (seltype == 'y/n') or (seltype == 'n/y'):
+				if config[selname] == 'y':
 					config[selname] = 'n'
 				else:
