#!/usr/bin/env python3 # encoding: utf-8 import struct def merge_ranges(*ranges): # Use a set for efficient lookup result = set() for rng in ranges: result.update(rng) return result def processtable(inputfilename, outfile, highrange, lowrange): with open(inputfilename) as f: res = dict(((x << 8) | y, 0) for x in highrange for y in lowrange) for line in f: if line.startswith('#'): continue splits = line.split() if len(splits[0]) <= 5: continue key = int(splits[0], 16) val = int(splits[1], 16) high = (key >> 8) & 0xff low = key & 0xff if high not in highrange or low not in lowrange: continue res[key] = val for (k, v) in sorted(res.items()): outfile.write(struct.pack("