in scripts/ValidateParameters/netaddr/eui/ieee.py [0:0]
def parse(self):
"""
Starts the parsing process which detects records and notifies
registered subscribers as it finds each IAB record.
"""
skip_header = True
record = None
size = 0
hex_marker = _bytes_type('(hex)')
base16_marker = _bytes_type('(base 16)')
hyphen = _bytes_type('-')
empty_string = _bytes_type('')
while True:
line = self.fh.readline()
if not line:
break # EOF, we're done
if skip_header and hex_marker in line:
skip_header = False
if skip_header:
# ignoring header section
continue
if hex_marker in line:
# record start
if record is not None:
record.append(size)
self.notify(record)
offset = (self.fh.tell() - len(line))
iab_prefix = line.split()[0]
index = iab_prefix
record = [index, offset]
size = len(line)
elif base16_marker in line:
# within record
size += len(line)
prefix = record[0].replace(hyphen, empty_string)
suffix = line.split()[0]
suffix = suffix.split(hyphen)[0]
record[0] = (int(prefix + suffix, 16)) >> 12
else:
# within record
size += len(line)
# process final record on loop exit
record.append(size)
self.notify(record)