def bgp_table_parser(bgp_table):
bgp_table = bgp_table.strip()<EOL>for bgp_entry in bgp_table.splitlines():<EOL><INDENT>bgp_table_fields = bgp_entry.split()<EOL>try:<EOL><INDENT>if re.search(r"<STR_LIT>", bgp_entry):<EOL><INDENT>(<EOL>peer_ip,<EOL>bgp_version,<EOL>remote_as,<EOL>msg_rcvd,<EOL>msg_sent,<EOL>_,<EOL>_,<EOL>_,<EOL>uptime,<EOL>state_1,<EOL>state_2,<EOL>) = bgp_table_fields<EOL>state_pfxrcd = "<STR_LIT>".format(state_1, state_2)<EOL><DEDENT>else:<EOL><INDENT>(<EOL>peer_ip,<EOL>bgp_version,<EOL>remote_as,<EOL>msg_rcvd,<EOL>msg_sent,<EOL>_,<EOL>_,<EOL>_,<EOL>uptime,<EOL>state_pfxrcd,<EOL>) = bgp_table_fields<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(bgp_table_fields)<EOL>)<EOL><DEDENT>is_enabled = True<EOL>try:<EOL><INDENT>received_prefixes = int(state_pfxrcd)<EOL>is_up = True<EOL><DEDENT>except ValueError:<EOL><INDENT>received_prefixes = -<NUM_LIT:1><EOL>is_up = False<EOL>if re.search(r"<STR_LIT>", state_pfxrcd):<EOL><INDENT>is_enabled = False<EOL><DEDENT><DEDENT>if not is_up:<EOL><INDENT>uptime = -<NUM_LIT:1><EOL><DEDENT>if uptime != -<NUM_LIT:1>:<EOL><INDENT>uptime = bgp_time_conversion(uptime)<EOL><DEDENT>yield {<EOL>peer_ip: {<EOL>"<STR_LIT>": is_enabled,<EOL>"<STR_LIT>": uptime,<EOL>"<STR_LIT>": helpers.as_number(remote_as),<EOL>"<STR_LIT>": is_up,<EOL>"<STR_LIT:description>": "<STR_LIT>",<EOL>"<STR_LIT>": received_prefixes,<EOL>}<EOL>}<EOL><DEDENT>
Generator that parses a line of bgp summary table and returns a dict compatible with NAPALM

    Example line:
    10.2.1.14       4    10  472516  472238      361    0    0     3w1d 9