Parse the uint32 PRIORITY field into its constituent parts from RFC 5245, type preference, local preference, and (256 - component ID). ex: 126 | 32252 | 255 (126 is host preference, 255 is component ID 1)
499931
function formatPriority(priority) {
        var s = '';
        s += (priority >> 24);
        s += ' | ';
        s += (priority >> 8) & 0xFFFF;
        s += ' | ';
        s += priority & 0xFF;
        return s;
    }
730902
function parsePorts(arg) {
  // coerce and split
  var ports = ('' + arg).split(':');
  if (ports.length !== 2) {
    panic('Error parsing ports.');
  }

  // parse ints
  var devicePort = Number((ports[0] === '') ? NaN : ports[0])
    , relayPort = Number((ports[1] === '') ? NaN : ports[1]);

  // NaN check em
  if (devicePort !== devicePort || relayPort !== relayPort) {
    panic('Error parsing ports.');
  }

  return [devicePort, relayPort];
}
1138077
private String parseDestinationHeader(HttpServletRequest req) {

        // Parsing destination header
        String destinationPath = req.getHeader(HEADER_DESTINATION);

        if (destinationPath == null) {
            return null;
        }

        // Remove url encoding from destination
        destinationPath = CmsEncoder.decode(destinationPath, "UTF8");

        int protocolIndex = destinationPath.indexOf("://");
        if (protocolIndex >= 0) {

            // if the Destination URL contains the protocol, we can safely
            // trim everything upto the first "/" character after "://"
            int firstSeparator = destinationPath.indexOf("/", protocolIndex + 4);
            if (firstSeparator < 0) {
                destinationPath = "/";
            } else {
                destinationPath = destinationPath.substring(firstSeparator);
            }
        } else {
            String hostName = req.getServerName();
            if ((hostName != null) && (destinationPath.startsWith(hostName))) {
                destinationPath = destinationPath.substring(hostName.length());
            }

            int portIndex = destinationPath.indexOf(":");
            if (portIndex >= 0) {
                destinationPath = destinationPath.substring(portIndex);
            }

            if (destinationPath.startsWith(":")) {
                int firstSeparator = destinationPath.indexOf("/");
                if (firstSeparator < 0) {
                    destinationPath = "/";
                } else {
                    destinationPath = destinationPath.substring(firstSeparator);
                }
            }
        }

        // Normalise destination path (remove '.' and '..')
        destinationPath = normalize(destinationPath);

        String contextPath = req.getContextPath();
        if ((contextPath != null) && (destinationPath.startsWith(contextPath))) {
            destinationPath = destinationPath.substring(contextPath.length());
        }

        String pathInfo = req.getPathInfo();
        if (pathInfo != null) {
            String servletPath = req.getServletPath();
            if ((servletPath != null) && (destinationPath.startsWith(servletPath))) {
                destinationPath = destinationPath.substring(servletPath.length());
            }
        }

        return destinationPath;
    }
528723
def get_uint32(self):
        

        token = self.get().unescape()
        if not token.is_identifier():
            raise dns.exception.SyntaxError('expecting an identifier')
        if not token.value.isdigit():
            raise dns.exception.SyntaxError('expecting an integer')
        value = long(token.value)
        if value < 0 or value > 4294967296L:
            raise dns.exception.SyntaxError('%d is not an unsigned 32-bit integer' % value)
        return value
853052
public static int parsePortFromHostAndPort(String urlPort, int defaultPort) {
        return urlPort.lastIndexOf(':') > 0 ? Integer.valueOf(urlPort.substring(urlPort.lastIndexOf(':') + 1,
                urlPort.length())) : defaultPort;
    }
731965
def parse_host(cls, host):
        ''''''
        if host.endswith(']'):
            return cls.parse_hostname(host), None
        else:
            hostname, sep, port = host.rpartition(':')

        if sep:
            port = int(port)
            if port < 0 or port > 65535:
                raise ValueError('Port number invalid')
        else:
            hostname = port
            port = None

        return cls.parse_hostname(hostname), port
356019
def parse_endpoint(inputendpoint_xml)
      hash = Hash.new
      %w{LoadBalancedEndpointSetName LocalPort Name Port Protocol EnableDirectServerReturn LoadBalancerName IdleTimeoutInMinutes}.each do |key|
        hash[key] = xml_content(inputendpoint_xml, key, nil)
      end
      # Protocol could be in there twice... If we have two, pick the second one as the first is for the probe.
      if inputendpoint_xml.css("Protocol").count > 1
        hash["Protocol"] = inputendpoint_xml.css("Protocol")[1].content
      end
      probe = inputendpoint_xml.css("LoadBalancerProbe")
      if probe
        hash["LoadBalancerProbe"] = Hash.new
        %w{Path Port Protocol IntervalInSeconds TimeoutInSeconds}.each do |key|
          hash["LoadBalancerProbe"][key] = xml_content(probe, key, nil)
        end
      end
      hash
    end
444526
function splitHostPort(hostport) {

   let host = hostport;
   let port = 80;
   const parts = hostport.split(':');
   if (parts.length > 1) {
      host = parts[0];
      port = parts[1];
   }

   return {'host': host, 'port': port};
}
464659
def _parse_bridge_opts(opts, iface):
    '''
    
    '''
    config = {}

    if 'ports' in opts:
        if isinstance(opts['ports'], list):
            opts['ports'] = ' '.join(opts['ports'])
        config.update({'ports': opts['ports']})

    for opt in ['ageing', 'fd', 'gcint', 'hello', 'maxage']:
        if opt in opts:
            try:
                float(opts[opt])
                config.update({opt: opts[opt]})
            except ValueError:
                _raise_error_iface(iface, opt, ['float'])

    for opt in ['bridgeprio', 'maxwait']:
        if opt in opts:
            if isinstance(opts[opt], int):
                config.update({opt: opts[opt]})
            else:
                _raise_error_iface(iface, opt, ['integer'])

    if 'hw' in opts:
        # match 12 hex digits with either : or - as separators between pairs
        if re.match('[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$',
                    opts['hw'].lower()):
            config.update({'hw': opts['hw']})
        else:
            _raise_error_iface(iface, 'hw', ['valid MAC address'])

    for opt in ['pathcost', 'portprio']:
        if opt in opts:
            try:
                port, cost_or_prio = opts[opt].split()
                int(cost_or_prio)
                config.update({opt: '{0} {1}'.format(port, cost_or_prio)})
            except ValueError:
                _raise_error_iface(iface, opt, ['interface integer'])

    if 'stp' in opts:
        if opts['stp'] in _CONFIG_TRUE:
            config.update({'stp': 'on'})
        elif opts['stp'] in _CONFIG_FALSE:
            config.update({'stp': 'off'})
        else:
            _raise_error_iface(iface, 'stp', _CONFIG_TRUE + _CONFIG_FALSE)

    if 'waitport' in opts:
        if isinstance(opts['waitport'], int):
            config.update({'waitport': opts['waitport']})
        else:
            values = opts['waitport'].split()
            waitport_time = values.pop(0)
            if waitport_time.isdigit() and values:
                config.update({
                    'waitport': '{0} {1}'.format(
                        waitport_time, ' '.join(values)
                    )
                })
            else:
                _raise_error_iface(iface, opt, ['integer [interfaces]'])

    return config
471969
def _parse_protocol_psutil(self, conn):
        
        protocol = self.PSUTIL_TYPE_MAPPING.get(conn.type, '')
        family = self.PSUTIL_FAMILY_MAPPING.get(conn.family, '')
        return '{}{}'.format(protocol, family)
745956
def _parse_canonical_int32(doc):
    """"""
    i_str = doc['$numberInt']
    if len(doc) != 1:
        raise TypeError('Bad $numberInt, extra field(s): %s' % (doc,))
    if not isinstance(i_str, string_type):
        raise TypeError('$numberInt must be string: %s' % (doc,))
    return int(i_str)
676249
def host(value):
    
    if not value:
        return (True, "")
    try:
        host,port = value.split(":")
    except ValueError as _:
        return (False, "value needs to be <host>:<port>")

    try:
        int(port)
    except ValueError as _:
        return (False, "port component of the host address needs to be a number")

    return (True, "")
195351
public static HostAndPort parse(String hostPortString) {

        LettuceAssert.notNull(hostPortString, "HostPortString must not be null");
        String host;
        String portString = null;

        if (hostPortString.startsWith("[")) {
            String[] hostAndPort = getHostAndPortFromBracketedHost(hostPortString);
            host = hostAndPort[0];
            portString = hostAndPort[1];
        } else {
            int colonPos = hostPortString.indexOf(':');
            if (colonPos >= 0 && hostPortString.indexOf(':', colonPos + 1) == -1) {
                // Exactly 1 colon. Split into host:port.
                host = hostPortString.substring(0, colonPos);
                portString = hostPortString.substring(colonPos + 1);
            } else {
                // 0 or 2+ colons. Bare hostname or IPv6 literal.
                host = hostPortString;
            }
        }

        int port = NO_PORT;
        if (!LettuceStrings.isEmpty(portString)) {
            // Try to parse the whole port string as a number.
            // JDK7 accepts leading plus signs. We don't want to.
            LettuceAssert.isTrue(!portString.startsWith("+"), String.format("Cannot port number: %s", hostPortString));
            try {
                port = Integer.parseInt(portString);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(String.format("Cannot parse port number: %s", hostPortString));
            }
            LettuceAssert.isTrue(isValidPort(port), String.format("Port number out of range: %s", hostPortString));
        }

        return new HostAndPort(host, port);
    }
962858
function addressFor(network, rnd) {
  var version = PROTOCOL_VERSIONS[network];

  //                      ver   payload  checksum
  var packed = new Buffer('00' + rnd + '00112233', 'hex');

  packed[0] = version;

  var hash = crypto.createHash('sha256').update(packed.slice(0, packed.length - 4)).digest();

  hash = crypto.createHash('sha256').update(hash).digest();

  packed[packed.length - 4] = hash[0];
  packed[packed.length - 3] = hash[1];
  packed[packed.length - 2] = hash[2];
  packed[packed.length - 1] = hash[3];

  return base58(packed);
}
554378
@Override
    protected void parse() throws ProtocolException {
        cursor = offset;
        optimalEncodingMessageSize = 4;

        // version
        version = readUint32();
        // peek at marker
        byte marker = payload[cursor];
        boolean useSegwit = marker == 0;
        // marker, flag
        if (useSegwit) {
            readBytes(2);
            optimalEncodingMessageSize += 2;
        }
        // txin_count, txins
        parseInputs();
        // txout_count, txouts
        parseOutputs();
        // script_witnesses
        if (useSegwit)
            parseWitnesses();
        // lock_time
        lockTime = readUint32();
        optimalEncodingMessageSize += 4;

        length = cursor - offset;
    }
690101
public static int parseNumericAddress(String ipaddr) {
    Matcher m = IP_ADDRESS_PATTERN.matcher(ipaddr);
    int ipInt = 0;
    if (m.find()) {
      for (int i = 1;i < 5;i++) 
        try {
          int ipVal = Integer.valueOf(m.group(i)).intValue();
          if ( ipVal < 0 || ipVal > 255) {
            return 0;
          }
          //  Add to the integer address
          ipInt = (ipInt << 8) + ipVal;
        }
        catch (NumberFormatException ex) {
          return 0;
        }
    }
    //  Return the integer address
    return ipInt;
  }
484478
def __parse_addr(self, addr):
        

        from email.utils import parseaddr

        value = parseaddr(addr)
        return value[0], value[1]