original_docstring: Only keep IP addresses that belong to a network
docstring: Only keep IP addresses that belong to a network
docstring_tokens: Only keep IP addresses that belong to a network
code: def filter_by_known_networks(self):
          """Only keep IP addresses that belong to a network"""
          known_networks = set(self.ipnetdb.ipv4_networks.values())
          known_networks.update(self.ipnetdb.ipv6_networks.values())
          logger.info("Filtering IP addresses to only include those which belong to %d known networks",
                      len(known_networks))
          for ips in self.hwaddrdb.ip_for_hw.values():
              for ip_addr in list(ips):
                  ip_addr_obj = ipaddress.ip_address(unicode_ip_addr(ip_addr))
                  if all(ip_addr_obj not in net_obj for net_obj in known_networks):
                      ips.remove(ip_addr)
                      try:
                          self.hwaddrdb.known_ip_addresses.remove(ip_addr)
                      except KeyError:
                          pass
  
          self.remove_non_hw_ip()
code_tokens: def filter_by_known_networks ( self ) : known_networks = set ( self . ipnetdb . ipv4_networks . values ( ) ) known_networks . update ( self . ipnetdb . ipv6_networks . values ( ) ) logger . info ( "Filtering IP addresses to only include those which belong to %d known networks" , len ( known_networks ) ) for ips in self . hwaddrdb . ip_for_hw . values ( ) : for ip_addr in list ( ips ) : ip_addr_obj = ipaddress . ip_address ( unicode_ip_addr ( ip_addr ) ) if all ( ip_addr_obj not in net_obj for net_obj in known_networks ) : ips . remove ( ip_addr ) try : self . hwaddrdb . known_ip_addresses . remove ( ip_addr ) except KeyError : pass self . remove_non_hw_ip ( )
short_docstring: Only keep IP addresses that belong to a network
short_docstring_tokens: Only keep IP addresses that belong to a network
comment: """Only keep IP addresses that belong to a network"""