Given a list of capability URI's returns <hello> message XML string
6184
def build(capabilities, device_handler):
        ""
        if device_handler:
            # This is used as kwargs dictionary for lxml's Element() function.
            # Therefore the arg-name ("nsmap") is used as key here.
            xml_namespace_kwargs = { "nsmap" : device_handler.get_xml_base_namespace_dict() }
        else:
            xml_namespace_kwargs = {}
        hello = new_ele("hello", **xml_namespace_kwargs)
        caps = sub_ele(hello, "capabilities")
        def fun(uri): sub_ele(caps, "capability").text = uri
        #python3 changes
        if sys.version < '3':
            map(fun, capabilities)
        else:
            list(map(fun, capabilities))
        return to_xml(hello)
1129638
function parseUri(str) {
    var parser = re.uri_parser;
    var parserKeys = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "isColonUri", "relative", "path", "directory", "file", "query", "anchor"];
    var m = parser.exec(str || '');
    var parts = {};

    parserKeys.forEach(function(key, i) {
      parts[key] = m[i] || '';
    });

    return parts;
  }
447336
public static String getCandidateSurt(UsableURI u) {
        if (u == null) {
            return null;
        }
        String candidateSurt = u.getSurtForm();
        // also want to treat https as http
        candidateSurt = coerceFromHttpsForComparison(candidateSurt);
        return candidateSurt;
    }
781500
@Override
    public Set<URI> listOptionalParts(URI messageContent) {
        if (messageContent == null) {
            return ImmutableSet.of();
        }

        return ImmutableSet.copyOf(this.messageOptionalPartsMap.get(messageContent));
    }
862573
def __parse_uri(self):
        """"""
        if self.scheme:
            scheme = '{}://'.format(self.scheme)
        else:
            scheme = ''

        credentials = self.username or ''
        password = self.password or ''

        if credentials and password:
            credentials = self.username + ':' + self.password
        if credentials:
            credentials += '@'

        if self.port:
            location = '{}:{}'.format(self.host, self.port)
        else:
            location = self.host

        path = self.path or ''

        if self.query:
            query = '?' + self.query
        else:
            query = ''

        if self.fragment:
            fragment = '#' + self.fragment
        else:
            fragment = ''

        return scheme + credentials + location + path + query + fragment
371867
def get_spaces(**kwargs):
    
    url = "/r25ws/servlet/wrd/run/spaces.xml"
    if len(kwargs):
        url += "?%s" % urlencode(kwargs)

    return spaces_from_xml(get_resource(url))
691471
private void parseURIIntoComponents() {
        List<String> pathNodeList = new ArrayList<String>();
        StringBuilder query = new StringBuilder();
        StringBuilder fragment = new StringBuilder();
        Utils.parseURI(getURI(), pathNodeList, query, fragment);
        for (String encodedNode : pathNodeList) {
            m_pathNodes.add(Utils.urlDecode(encodedNode));
        }
        m_query = Utils.urlDecode(query.toString());
    }
253638
def write_source_description(
            self, capability_lists=None, outfile=None, links=None):
        """"""
        rsd = SourceDescription(ln=links)
        rsd.pretty_xml = self.pretty_xml
        if (capability_lists is not None):
            for uri in capability_lists:
                rsd.add_capability_list(uri)
        if (outfile is None):
            print(rsd.as_xml())
        else:
            rsd.write(basename=outfile)
464717
@Override
    public Set<URI> listMandatoryParts(URI messageContent) {
        if (messageContent == null || !messageContent.isAbsolute()) {
            log.warn("The Message Content URI is either absent or relative. Provide an absolute URI");
            return ImmutableSet.of();
        }

        URI graphUri;
        try {
            graphUri = getGraphUriForElement(messageContent);
        } catch (URISyntaxException e) {
            log.warn("The namespace of the URI of the message content is incorrect.", e);
            return ImmutableSet.of();
        }

        if (graphUri == null) {
            log.warn("Could not obtain a graph URI for the element. The URI may not be managed by the server - " + messageContent);
            return ImmutableSet.of();
        }

        String queryStr = new StringBuilder()
                .append("SELECT DISTINCT ?part WHERE { \n")
                .append(" GRAPH <").append(graphUri.toASCIIString()).append("> { \n")
                .append("<").append(messageContent.toASCIIString()).append("> ").append("<").append(MSM.hasMandatoryPart.getURI()).append(">").append(" ?part .")
                .append("?part ").append("<").append(RDF.type.getURI()).append(">").append(" ").append("<").append(MSM.MessagePart.getURI()).append("> .")
                .append(" } \n ")
                .append("} \n ")
                .toString();

        return this.graphStoreManager.listResourcesByQuery(queryStr, "part");
    }
1096175
def string(self) -> bytes:
        """"""
        if self._raw is not None:
            return self._raw
        self._raw = raw = BytesFormat(b' ').join(
            [b'CAPABILITY', b'IMAP4rev1'] + self.capabilities)
        return raw
819788
def namespace_from_uri(uri):
    
    patterns = ['http://www.openbel.org/bel/[pragm]_([A-Za-z]+)_.*',
                'http://www.openbel.org/bel/[a-z]+_[pr]_([A-Za-z]+)_.*',
                'http://www.openbel.org/bel/[a-z]+_complex_([A-Za-z]+)_.*',
                'http://www.openbel.org/bel/complex_([A-Za-z]+)_.*']
    for pr in patterns:
        match = re.match(pr, uri)
        if match is not None:
            return match.groups()[0]
    return None
397375
def to_s
      if self.scheme == nil && self.path != nil && !self.path.empty? &&
          self.path =~ NORMPATH
        raise InvalidURIError,
          "Cannot assemble URI string with ambiguous path: '#{self.path}'"
      end
      @uri_string ||= begin
        uri_string = String.new
        uri_string << "#{self.scheme}:" if self.scheme != nil
        uri_string << "//#{self.authority}" if self.authority != nil
        uri_string << self.path.to_s
        uri_string << "?#{self.query}" if self.query != nil
        uri_string << "##{self.fragment}" if self.fragment != nil
        uri_string.force_encoding(Encoding::UTF_8)
        uri_string
      end
    end
1052462
def build_self_uri_list(self_uri_list):
    ""
    uri_list = []
    for self_uri in self_uri_list:
        uri = ea.Uri()
        utils.set_attr_if_value(uri, 'xlink_href', self_uri.get('xlink_href'))
        utils.set_attr_if_value(uri, 'content_type', self_uri.get('content-type'))
        uri_list.append(uri)
    return uri_list
302653
private <L extends Collection<ContentUriPlaceHolder>> L extractPlaceHoldersFromURI(String uri, final L result) {
		final One<Boolean> valid = new One<>();
		valid.value0 = false;

		analyzeInternal(uri, new UriBaseListener() {

			@Override
			public void enterBind_parameter(Bind_parameterContext ctx) {
				result.add(new ContentUriPlaceHolder(pathSegmentIndex, ctx.bind_parameter_name().getText()));
			}

			@Override
			public void enterPath_segment(Path_segmentContext ctx) {
				pathSegmentIndex++;
			}

		});
		return result;
	}
576169
def match(self, url):
        
        return list({
            message for message in self.active() if
            message.is_global or message.match(url)
        })
231718
def get_content_string(self):
        
        return ''.join([ET.tostring(element, encoding="utf-8", method="xml")
                        for element in list(self._content)])
1284343
@Override
    public Set<Capability> getCapabilities(FileSystem fs, Path path) {
        if (logger.isDebugEnabled()) {
            logger.debug("orc file path: " + path.toUri().getPath());
        }

        Reader orcReader = null;
        RecordReader recordReader = null;
        try {
            // no need to close orcreader
            orcReader = OrcFile.createReader(fs, path);
            recordReader = orcReader.rows(null);
        } catch (Exception e) {
            if (logger.isDebugEnabled()) {
                logger.debug(path.toUri().getPath() + " is not a ORC file.");
                logger.debug("Error in opening ORC file: "
                    + e.getLocalizedMessage());
            }
            return EnumSet.noneOf(Capability.class);
        } finally {
            if (recordReader != null) {
                try {
                    recordReader.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
        }
        return EnumSet.of(Capability.READ, Capability.SCHEMA);
    }