def parse(fn):
	
	zones, rules, zone = {}, {}, None
	for ln in lines(fn):
		
		# see zic(8) for documentation
		words = WS_SPLIT.split(ln)
		if words[0] == 'Zone':
			assert words[1] not in zones, words[1]
			zone = []
			zone.append(zoneline(words[2:]))
			if '/' in words[1]:
				zones[words[1]] = zone
		
		elif words[0] == '':
			assert zone is not None
			zone.append(zoneline(words[1:]))
			
		elif words[0] == 'Rule':
			zone = None
			words[8] = offset(words[8])
			rule = rules.setdefault(words[1], [])
			rule.append(words[2:])
			
		elif words[0] == 'Link':
			zone = None # ignore
		else:
			assert False, ln
	
	return {'zones': zones, 'rules': rules}
dataset/ETHPy150Open djc/awmy/zones.py/parse/original