code: def cmd_nmap_ports(scanfile, protocol):
      
  
      data = scanfile.read()
      fmt = detect_format(data)
  
      if fmt not in ['xml', 'nmap', 'gnmap']:
          print('Unknown file format.', file=sys.stdout)
          return 1
  
      if fmt == 'nmap':
          result = parse_format_nmap(data, protocol)
      elif fmt == 'gnmap':
          result = parse_format_gnmap(data, protocol)
      elif fmt == 'xml':
          result = parse_format_xml(data, protocol)
  
      print(result, end='')
  
      return True
docs: Read an nmap report and print the tested ports.
  
      Print the ports that has been tested reading the generated nmap output.
  
      You can use it to rapidly reutilize the port list for the input of other tools.
  
      Supports and detects the 3 output formats (nmap, gnmap and xml)
  
      Example:
  
      \b
      # habu.nmap.ports portantier.nmap
      21,22,23,80,443