Skip to content

Instantly share code, notes, and snippets.

@tyler-8
Created April 4, 2018 18:36
Show Gist options
  • Select an option

  • Save tyler-8/50554899bf76e664c37cec67c5cd4a1d to your computer and use it in GitHub Desktop.

Select an option

Save tyler-8/50554899bf76e664c37cec67c5cd4a1d to your computer and use it in GitHub Desktop.

Revisions

  1. tyler-8 created this gist Apr 4, 2018.
    18 changes: 18 additions & 0 deletions portlist.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    def parsePortList(portlist):
    """
    Returns indexes of ports where
    VLAN is present.
    """
    port_status = []
    present_ports = []
    for values in portlist:
    for i, bit in enumerate('{:08b}'.format(values)):
    bit = int(bit)
    if bit:
    port_status.append(True)
    else:
    port_status.append(False)
    for index, state in enumerate(port_status):
    if state:
    present_ports.append(index+1)
    return present_ports