code: def _get_compressed_vlan_list(self, pvlan_ids):
          
  
          if not pvlan_ids:
              return []
  
          pvlan_list = list(pvlan_ids)
          pvlan_list.sort()
          compressed_list = []
          begin = -1
          prev_vlan = -1
          for port_vlan in pvlan_list:
              if prev_vlan == -1:
                  prev_vlan = port_vlan
              else:
                  if (port_vlan - prev_vlan) == 1:
                      if begin == -1:
                          begin = prev_vlan
                      prev_vlan = port_vlan
                  else:
                      if begin == -1:
                          compressed_list.append(str(prev_vlan))
                      else:
                          compressed_list.append("%d-%d" % (begin, prev_vlan))
                          begin = -1
                      prev_vlan = port_vlan
  
          if begin == -1:
              compressed_list.append(str(prev_vlan))
          else:
              compressed_list.append("%s-%s" % (begin, prev_vlan))
          return compressed_list
docs: Generate a compressed vlan list ready for XML using a vlan set.
  
          Sample Use Case:
  
          Input vlan set:
          --------------
          1 - s = set([11, 50, 25, 30, 15, 16, 3, 8, 2, 1])
          2 - s = set([87, 11, 50, 25, 30, 15, 16, 3, 8, 2, 1, 88])
  
          Returned compressed XML list:
          ----------------------------
          1 - compressed_list = ['1-3', '8', '11', '15-16', '25', '30', '50']
          2 - compressed_list = ['1-3', '8', '11', '15-16', '25', '30',
                                 '50', '87-88']