def parse_header(head):
try:<EOL><INDENT>(fromcall, path) = head.split('<STR_LIT:>>', <NUM_LIT:1>)<EOL><DEDENT>except:<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT>if (not <NUM_LIT:1> <= len(fromcall) <= <NUM_LIT:9> or<EOL>not re.findall(r"<STR_LIT>", fromcall, re.I)):<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT>path = path.split('<STR_LIT:U+002C>')<EOL>if len(path[<NUM_LIT:0>]) == <NUM_LIT:0>:<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT>tocall = path[<NUM_LIT:0>]<EOL>path = path[<NUM_LIT:1>:]<EOL>validate_callsign(tocall, "<STR_LIT>")<EOL>for digi in path:<EOL><INDENT>if not re.findall(r"<STR_LIT>", digi, re.I):<EOL><INDENT>raise ParseError("<STR_LIT>")<EOL><DEDENT><DEDENT>parsed = {<EOL>'<STR_LIT>': fromcall,<EOL>'<STR_LIT:to>': tocall,<EOL>'<STR_LIT:path>': path,<EOL>}<EOL>viacall = "<STR_LIT>"<EOL>if len(path) >= <NUM_LIT:2> and re.match(r"<STR_LIT>", path[-<NUM_LIT:2>]):<EOL><INDENT>viacall = path[-<NUM_LIT:1>]<EOL><DEDENT>parsed.update({'<STR_LIT>': viacall})<EOL>return parsed<EOL>
Parses the header part of packet
Returns a dict