def parse_intf_section(interface):
interface = interface.strip()<EOL>re_protocol = (<EOL>r"<STR_LIT>"<EOL>r"<STR_LIT>"<EOL>)<EOL>re_intf_name_state = r"<STR_LIT>"<EOL>re_is_enabled_1 = r"<STR_LIT>"<EOL>re_is_enabled_2 = r"<STR_LIT>"<EOL>re_is_enabled_3 = r"<STR_LIT>"<EOL>re_mac = r"<STR_LIT>"<EOL>re_speed = (<EOL>r"<STR_LIT>"<EOL>)<EOL>re_mtu_nve = r"<STR_LIT>"<EOL>re_description_1 = r"<STR_LIT>"<EOL>re_description_2 = r"<STR_LIT>"<EOL>re_hardware = r"<STR_LIT>"<EOL>match = re.search(re_protocol, interface, flags=re.M)<EOL>if match:<EOL><INDENT>intf_name = match.group("<STR_LIT>")<EOL>status = match.group("<STR_LIT:status>")<EOL>protocol = match.group("<STR_LIT>")<EOL>if "<STR_LIT>" in status.lower():<EOL><INDENT>is_enabled = False<EOL><DEDENT>else:<EOL><INDENT>is_enabled = True<EOL><DEDENT>is_up = bool("<STR_LIT>" in protocol)<EOL><DEDENT>else:<EOL><INDENT>match = re.search(re_intf_name_state, interface)<EOL>intf_name = match.group("<STR_LIT>")<EOL>intf_state = match.group("<STR_LIT>").strip()<EOL>is_up = True if intf_state == "<STR_LIT>" else False<EOL>admin_state_present = re.search("<STR_LIT>", interface)<EOL>if admin_state_present:<EOL><INDENT>for x_pattern in [re_is_enabled_1, re_is_enabled_2]:<EOL><INDENT>match = re.search(x_pattern, interface, flags=re.M)<EOL>if match:<EOL><INDENT>is_enabled = match.group("<STR_LIT>").strip()<EOL>is_enabled = True if re.search("<STR_LIT>", is_enabled) else False<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>msg = "<STR_LIT>".format(<EOL>interface<EOL>)<EOL>raise ValueError(msg)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>is_enabled = True<EOL>if not is_up:<EOL><INDENT>match = re.search(re_is_enabled_3, interface, flags=re.M)<EOL>if match:<EOL><INDENT>is_enabled = False<EOL><DEDENT><DEDENT><DEDENT><DEDENT>match = re.search(re_mac, interface, flags=re.M)<EOL>if match:<EOL><INDENT>mac_address = match.group("<STR_LIT>")<EOL>mac_address = helpers.mac(mac_address)<EOL><DEDENT>else:<EOL><INDENT>mac_address = "<STR_LIT>"<EOL><DEDENT>match = re.search(re_hardware, interface, flags=re.M)<EOL>speed_exist = True<EOL>if match:<EOL><INDENT>if match.group("<STR_LIT>") == "<STR_LIT>":<EOL><INDENT>match = re.search(re_mtu_nve, interface, flags=re.M)<EOL>mtu = int(match.group("<STR_LIT>"))<EOL>speed_exist = False<EOL><DEDENT><DEDENT>if speed_exist:<EOL><INDENT>match = re.search(re_speed, interface, flags=re.M)<EOL>speed = int(match.group("<STR_LIT>"))<EOL>mtu = int(match.group("<STR_LIT>"))<EOL>speed_unit = match.group("<STR_LIT>")<EOL>speed_unit = speed_unit.rstrip("<STR_LIT:U+002C>")<EOL>if speed_unit != "<STR_LIT>":<EOL><INDENT>msg = "<STR_LIT>".format(<EOL>interface<EOL>)<EOL>raise ValueError(msg)<EOL><DEDENT>speed = int(round(speed / <NUM_LIT>))<EOL><DEDENT>else:<EOL><INDENT>speed = -<NUM_LIT:1><EOL><DEDENT>description = "<STR_LIT>"<EOL>for x_pattern in [re_description_1, re_description_2]:<EOL><INDENT>match = re.search(x_pattern, interface, flags=re.M)<EOL>if match:<EOL><INDENT>description = match.group("<STR_LIT:description>")<EOL>break<EOL><DEDENT><DEDENT>return {<EOL>intf_name: {<EOL>"<STR_LIT:description>": description,<EOL>"<STR_LIT>": is_enabled,<EOL>"<STR_LIT>": is_up,<EOL>"<STR_LIT>": -<NUM_LIT:1.0>,<EOL>"<STR_LIT>": mac_address,<EOL>"<STR_LIT>": mtu,<EOL>"<STR_LIT>": speed,<EOL>}<EOL>}<EOL>
Parse a single entry from show interfaces output.

    Different cases:
    mgmt0 is up
    admin state is up

    Ethernet2/1 is up
    admin state is up, Dedicated Interface

    Vlan1 is down (Administratively down), line protocol is down, autostate enabled

    Ethernet154/1/48 is up (with no 'admin state')