# gegeven een file met een lijst van te gebruiken wleiden.conf's, print
# op stdout een file waar channelga.ml wat mee kan.
import re

first = 1

def parse_wleiden_conf(lines):
	global first
	essid = None
	wi = None
	for l in lines:
		if wi != None:
			match = re.match("^ESSID=(.*)", l)
			if match != None:
				print match.group(1),
			match = re.match("^EW[0-9]*", l)
			if match != None:
				wi = None
				essid = None
			match = re.match("^EOS", l)
			if match != None:
				wi = None
				essid = None
		else:
			match = re.match("^\$nodename='([^']*)';.*", l)
			if match != None:
				if first:
					first = 0
				else:
					print ""
				print match.group(1).lower(),
			match = re.match("^\$config{'wi[0-9]*:[0-9].*", l)
			if match != None:
				continue
			match = re.match("^\$config{'(wi[0-9]*).*", l)
			if match != None:
				print match.group(1).lower(),
				wi = 1

for fname in open('l').readlines():
	parse_wleiden_conf(open(fname[:-1]).readlines())

