original_docstring: Add an option to the given IP address
docstring: Add an option to the given IP address
docstring_tokens: Add an option to the given IP address
code: def add_option(self, ip_addr, kind, value, silent=False):
          """Add an option to the given IP address"""
          if ip_addr not in self.addr_opts:
              new_ip_addr = self.canonical_cache.get(ip_addr)
              if new_ip_addr is None:
                  new_ip_addr = canonical_ip_address(ip_addr)
                  if new_ip_addr != ip_addr:
                      if '::ffff:' + new_ip_addr != ip_addr:
                          # Only warns about non-V4MAPPED addresses
                          logger.warning("Tried adding a non-canonical IP address %r -> %r", ip_addr, new_ip_addr)
                      self.canonical_cache[ip_addr] = new_ip_addr
              ip_addr = new_ip_addr
              if ip_addr not in self.addr_opts:
                  self.addr_opts[ip_addr] = {}
          addr_options = self.addr_opts[ip_addr]
          if kind not in addr_options:
              addr_options[kind] = set()
          if value not in addr_options[kind]:
              # Add values which are prefix for other values, before they are
              # removed in the post-processing pass, in order to quicken things.
              if any(v.startswith(value) for v in addr_options[kind]):
                  logger.debug("Adding %s for %s even though an existing value shares a prefix: %r",
                               kind, ip_addr, value)
              elif not silent:
                  logger.info("Adding %s for %s: %r", kind, ip_addr, value)
              addr_options[kind].add(value)
code_tokens: def add_option ( self , ip_addr , kind , value , silent = False ) : if ip_addr not in self . addr_opts : new_ip_addr = self . canonical_cache . get ( ip_addr ) if new_ip_addr is None : new_ip_addr = canonical_ip_address ( ip_addr ) if new_ip_addr != ip_addr : if '::ffff:' + new_ip_addr != ip_addr : logger . warning ( "Tried adding a non-canonical IP address %r -> %r" , ip_addr , new_ip_addr ) self . canonical_cache [ ip_addr ] = new_ip_addr ip_addr = new_ip_addr if ip_addr not in self . addr_opts : self . addr_opts [ ip_addr ] = { } addr_options = self . addr_opts [ ip_addr ] if kind not in addr_options : addr_options [ kind ] = set ( ) if value not in addr_options [ kind ] : if any ( v . startswith ( value ) for v in addr_options [ kind ] ) : logger . debug ( "Adding %s for %s even though an existing value shares a prefix: %r" , kind , ip_addr , value ) elif not silent : logger . info ( "Adding %s for %s: %r" , kind , ip_addr , value ) addr_options [ kind ] . add ( value )
short_docstring: Add an option to the given IP address
short_docstring_tokens: Add an option to the given IP address
comment: """Add an option to the given IP address"""$SEP$# Only warns about non-V4MAPPED addresses$SEP$# Add values which are prefix for other values, before they are$SEP$# removed in the post-processing pass, in order to quicken things.