Depending on whether or not we're in testnet 
    or mainnet, re-encode an address accordingly.
968345
def btc_address_reencode( address, **blockchain_opts ):
    
    # re-encode bitcoin address
    network = blockchain_opts.get('network', None)
    opt_version_byte = blockchain_opts.get('version_byte', None)

    if btc_is_segwit_address(address):
        # bech32 address
        hrp = None
        if network == 'mainnet':
            hrp = 'bc'

        elif network == 'testnet':
            hrp = 'tb'

        else:
            if os.environ.get('BLOCKSTACK_TESTNET') == '1' or os.environ.get('BLOCKSTACK_TESTNET3') == '1':
                hrp = 'tb'

            else:
                hrp = 'bc'

        wver, whash = segwit_addr_decode(address)
        return segwit_addr_encode(whash, hrp=hrp, witver=wver)

    else:
        # base58 address
        vb = keylib.b58check.b58check_version_byte( address )

        if network == 'mainnet':
            if vb == 0 or vb == 111:
                vb = 0

            elif vb == 5 or vb == 196:
                vb = 5

            else:
                raise ValueError("Unrecognized address %s" % address)
        
        elif network == 'testnet':
            if vb == 0 or vb == 111:
                vb = 111
            
            elif vb == 5 or vb == 196:
                vb = 196

            else:
                raise ValueError("Unrecognized address %s" % address)

        else:
            if opt_version_byte is not None:
                vb = opt_version_byte

            elif os.environ.get("BLOCKSTACK_TESTNET") == "1" or os.environ.get("BLOCKSTACK_TESTNET3") == "1":
                if vb == 0 or vb == 111:
                    # convert to testnet p2pkh
                    vb = 111

                elif vb == 5 or vb == 196:
                    # convert to testnet p2sh
                    vb = 196

                else:
                    raise ValueError("unrecognized address %s" % address)

            else:
                if vb == 0 or vb == 111:
                    # convert to mainnet p2pkh
                    vb = 0

                elif vb == 5 or vb == 196:
                    # convert to mainnet p2sh
                    vb = 5

                else:
                    raise ValueError("unrecognized address %s" % address)

        return keylib.b58check.b58check_encode( keylib.b58check.b58check_decode(address), vb )
525311
def to_i
      self.address.split(':').inject(0) do |bits,char|
        bits = ((bits << 8) | char.hex)
      end
    end
691918
def modify(LowLayerCompatibility_presence=0,
           HighLayerCompatibility_presence=0,
           ReverseCallSetupDirection_presence=0):
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x17)  # 00010111
    c = BearerCapability()
    packet = a / b / c
    if LowLayerCompatibility_presence is 1:
        d = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0)
        packet = packet / d
    if HighLayerCompatibility_presence is 1:
        e = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0)
        packet = packet / e
    if ReverseCallSetupDirection_presence is 1:
        f = ReverseCallSetupDirectionHdr(ieiRCSD=0xA3)
        packet = packet / f
    return packet
1144262
private void decodeChunk(InetSocketAddress address, final ByteBuf chunk) {
    responseContent.writeBytes(chunk);

    String currentChunk = responseContent.toString(CharsetUtil.UTF_8);
    int separatorIndex = currentChunk.indexOf("\n\n\n\n");
    if (separatorIndex > 0) {
      String rawConfig = currentChunk
          .substring(0, separatorIndex)
          .trim()
          .replace("$HOST", address.getAddress().getHostAddress());

      NetworkAddress origin = NetworkAddress.create(address.getAddress().getHostAddress());
      CouchbaseBucketConfig config = (CouchbaseBucketConfig) BucketConfigParser.parse(rawConfig, environment, origin);
      synchronized (currentBucketConfigRev) {
        if (config.rev() > currentBucketConfigRev.get()) {
          LOGGER.trace("Publishing bucket config: {}", RedactableArgument.system(rawConfig));
          currentBucketConfigRev.set(config.rev());
          configStream.onNext(config);
        } else {
          LOGGER.trace("Ignoring config, since rev has not changed.");
        }
      }

      responseContent.clear();
      responseContent.writeBytes(currentChunk.substring(separatorIndex + 4).getBytes(CharsetUtil.UTF_8));
    }
  }
1084647
protected String replaceHostWildcard(String input, NetworkAddress hostname) {
        return input.replace("$HOST", hostname.address());
    }
1194823
def __try_read_byte_prev(self, address):
        
        # Initialize memory location with a random value
        if address not in self.__memory_prev:
            return False, None

        return True, self.__memory_prev[address]
29915
def Convert(self, metadata, interface, token=None):
    """"""
    ip4_addresses = []
    ip6_addresses = []
    for addr in interface.addresses:
      if addr.address_type == addr.Family.INET:
        ip4_addresses.append(addr.human_readable_address)
      elif addr.address_type == addr.Family.INET6:
        ip6_addresses.append(addr.human_readable_address)
      else:
        raise ValueError("Invalid address type: %s" % addr.address_type)

    result = ExportedNetworkInterface(
        metadata=metadata,
        ifname=interface.ifname,
        ip4_addresses=" ".join(ip4_addresses),
        ip6_addresses=" ".join(ip6_addresses))

    if interface.mac_address:
      result.mac_address = interface.mac_address.human_readable_address

    yield result
514473
def encode_network(root):
    """"""
    def fix_values(obj):
        if isinstance(obj, Container):
            obj.update((k, get_ref(v)) for (k, v) in obj.items()
                                       if k != 'class_name')
            fixed_obj = obj

        elif isinstance(obj, Dictionary):
            fixed_obj = obj.__class__(dict(
                (get_ref(field), get_ref(value))
                for (field, value) in obj.value.items()
            ))

        elif isinstance(obj, dict):
            fixed_obj = dict(
                (get_ref(field), get_ref(value))
                for (field, value) in obj.items()
            )

        elif isinstance(obj, list):
            fixed_obj = [get_ref(field) for field in obj]

        elif isinstance(obj, Form):
            fixed_obj = obj.__class__(**dict(
                (field, get_ref(value))
                for (field, value) in obj.value.items()
            ))

        elif isinstance(obj, ContainsRefs):
            fixed_obj = obj.__class__([get_ref(field)
                                       for field in obj.value])

        else:
            return obj

        fixed_obj._made_from = obj
        return fixed_obj

    objects = []

    def get_ref(obj, objects=objects):
        obj = PythonicAdapter(Pass)._encode(obj, None)

        if isinstance(obj, (FixedObject, Container)):
            if getattr(obj, '_index', None):
                index = obj._index
            else:
                objects.append(None)
                obj._index = index = len(objects)
                objects[index - 1] = fix_values(obj)
            return Ref(index)
        else:
            return obj # Inline value

    get_ref(root)

    for obj in objects:
        if getattr(obj, '_index', None):
            del obj._index
    return objects
1330985
def _normalize(self, addr):
        """"""
        normalize = None
        if isinstance(addr, Address):
            normalize = addr.addr
            self._is_x10 = addr.is_x10

        elif isinstance(addr, bytearray):
            normalize = binascii.unhexlify(binascii.hexlify(addr).decode())

        elif isinstance(addr, bytes):
            normalize = addr

        elif isinstance(addr, str):
            addr = addr.replace('.', '')
            addr = addr[0:6]
            if addr[0:3].lower() == 'x10':
                x10_addr = Address.x10(addr[3:4], int(addr[4:6]))
                normalize = x10_addr.addr
                self._is_x10 = True
            else:
                normalize = binascii.unhexlify(addr.lower())

        elif addr is None:
            normalize = None

        else:
            _LOGGER.warning('Address class init with unknown type %s: %r',
                            type(addr), addr)
        return normalize
1195099
def inet_pton(af, addr):
    """"""
    # Will replace Net/Net6 objects
    addr = plain_str(addr)
    # Use inet_pton if available
    try:
        return socket.inet_pton(af, addr)
    except AttributeError:
        try:
            return _INET_PTON[af](addr)
        except KeyError:
            raise socket.error("Address family not supported by protocol")
912649
public boolean isSuspect(String address) {
		for (NetworkAddress networkAddress : suspectNetworks) {
			if (networkAddress.isAddressInNetwork(address)) {
				return true;
			}
		}
		return false;
	}
655101
def _expand_address(addy):
    '''
    
    '''
    ret = {}
    ret.update(addy.__dict__)
    ret['extra']['zone'] = addy.region.name
    return ret
917129
private static byte[] encode(int witnessVersion, byte[] witnessProgram) throws AddressFormatException {
        byte[] convertedProgram = convertBits(witnessProgram, 0, witnessProgram.length, 8, 5, true);
        byte[] bytes = new byte[1 + convertedProgram.length];
        bytes[0] = (byte) (Script.encodeToOpN(witnessVersion) & 0xff);
        System.arraycopy(convertedProgram, 0, bytes, 1, convertedProgram.length);
        return bytes;
    }
1066245
private function handle_reassign_sites() {
		$to   = array_map( 'absint', (array) filter_input( INPUT_POST, 'to', FILTER_FORCE_ARRAY ) );
		$from = array_map( 'absint', (array) filter_input( INPUT_POST, 'from', FILTER_FORCE_ARRAY ) );

		// Bail early if no movement.
		if ( empty( $to ) && empty( $from ) ) {
			return;
		}

		$network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );

		$moving_to   = array();
		$moving_from = array();

		$sites_list = get_sites( array(
			'network_id' => $network_id,
			'fields'     => 'ids',
		) );

		// Move sites out of current network.
		foreach ( $from as $site_id ) {
			if ( in_array( $site_id, $sites_list, true ) ) {
				$moving_from[] = $site_id;
			}
		}

		// Move sites into current network.
		foreach ( $to as $site_id ) {
			if ( ! in_array( $site_id, $sites_list, true ) ) {
				$moving_to[] = $site_id;
			}
		}

		$moving = array_filter( array_merge( $moving_to, $moving_from ) );

		// Loop through and move sites.
		foreach ( $moving as $site_id ) {
			$site = get_site( $site_id );

			// Skip if missing or main site.
			if ( empty( $site ) || is_main_site( $site->id, $site->network_id ) ) {
				continue;
			}

			if ( in_array( $site_id, $to, true ) && ! in_array( $site_id, $sites_list, true ) ) {
				move_site( $site_id, $network_id );
			} elseif ( in_array( $site_id, $from, true ) ) {
				move_site( $site_id, 0 );
			}
		}
	}
921715
protected void checkAddress() {
    if (localAddress == null) {
      check++;
      if (check > 1000 && System.currentTimeMillis() - lastReset > 15000) {
        resetLocalAddress(null);
      }
    }
  }
157732
def mime_encode_address string
    return string if string.ascii_only?
    string.sub(RE_ADDRESS) { |match| mime_encode($1) + $2 }
  end
612273
static InetAddress inet4FromInt(int address) {
        byte[] addr = new byte[4];
        addr[0] = (byte) ((address >>> 24) & 0xFF);
        addr[1] = (byte) ((address >>> 16) & 0xFF);
        addr[2] = (byte) ((address >>> 8) & 0xFF);
        addr[3] = (byte) (address & 0xFF);
        try {
            return InetAddress.getByAddress(addr);
        } catch (UnknownHostException uhe) {
            throw new AssertionError("Should not reach here");
        }
    }