Given a uri return the qname if it exists, otherwise return the uri.
12721
def qname(self, uri, generate=False):
        
        try:
            prefix, namespace, name = self.g.namespace_manager.compute_qname(uri, generate=generate)
            qname = ':'.join((prefix, name))
            return qname
        except (KeyError, ValueError) as e:
            return uri.toPython() if isinstance(uri, rdflib.URIRef) else uri
1116535
def get_uri(self):
        """"""
        if self.source_file and os.path.exists(self.source_file.path):
            return self.source_file.path
        elif self.source_url:
            return self.source_url
        return None
426247
def get(self, uri, query=None, **kwargs):
        """"""
        return self.fetch('get', uri, query, **kwargs)
141323
def uri_from_fields(prefix, *fields):
        """"""
        string = '_'.join(AlignmentHelper.alpha_numeric(f.strip().lower(), '') for f in fields)

        if len(string) == len(fields) - 1:
            return ''

        return prefix + string
1012858
def _maybe_get_default_name(self, name):
        
        if name is None and self.uri.fragment:
            name = self.uri.fragment
        return name
850712
function uri_to_alias($uri) {
        try
        {
            $retVal = $this->uri_to_qname($uri);
        }
        catch (\Tripod\Exceptions\LabellerException $e) {}
        return (empty($retVal)) ? $uri : $retVal;
    }
1126105
def _expand_qname(self, qname):
        """"""
        if type(qname) is not rt.URIRef:
            raise TypeError("Cannot expand qname of type {}, must be URIRef"
                            .format(type(qname)))
        for ns in self.graph.namespaces():
            if ns[0] == qname.split(':')[0]:
                return rt.URIRef("%s%s" % (ns[1], qname.split(':')[-1]))
        return qname
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
1040337
def uri_read(*args, **kwargs):
    

    with uri_open(*args, **kwargs) as f:
        content = f.read()
    return content
368890
def _build_qname(self, uri=None, namespaces=None):
        
        if not uri:
            uri = self.uri
        if not namespaces:
            namespaces = self.namespaces
        return uri2niceString(uri, namespaces)
311103
def request_uri(self):
        
        result = '/{0}'.format(self.path.lstrip('/'))
        if self.query is not None and self.query != '' and self.query != {}:
            result += '?{0}'.format(self.encoded_query())
        if self.fragment is not None and self.fragment != '':
            result += '#{0}'.format(self.fragment)
        return result
1045630
def uri_from_parts(parts):
    ""
    uri = "%s://%s%s" % (parts[0], parts[1], parts[2])
    if parts[3]:
        extra = '?'+urlencode(parts[3])
        uri += extra
    return uri
962424
def plugin_name_by_uri(uri):
    ""

    # TODO: parse URIs like 'sqlite://' also
    parsed = urlparse(uri)
    basename = os.path.basename(parsed.path)

    if not basename.strip():
        raise RuntimeError("Could not identify file format.")

    plugin_name = basename.split(".")[-1].lower()
    if plugin_name in FILE_EXTENSIONS:
        plugin_name = MIME_TYPE_TO_PLUGIN_NAME[FILE_EXTENSIONS[plugin_name]]

    return plugin_name
1216839
function getPathnameFromUrl (u) {
	const pathname = url.parse(u).pathname;
	try {
		return decodeURI(pathname);
	} catch (e) {
		return pathname;
	}
}
1191183
def filename_to_uri(self, filename):
        """"""

        try:
            return self._uri_cache[filename]
        except KeyError:
            value = self._relativeize(filename)
            self._uri_cache[filename] = value
            return value
1281288
@SuppressWarnings("unchecked")
 public static <T> T lookup(URI rmiUrl)   
   {
	try
	{
	   return (T)Naming.lookup(rmiUrl.toString());
	}
	catch(Exception e)
	{
	   throw new ConnectionException(rmiUrl+" ERROR:"+Debugger.stackTrace(e));
	}	
   }
915489
function qname_to_alias($qname) {
        try
        {
            $retVal = $this->qname_to_uri($qname);
        }
        catch (\Tripod\Exceptions\LabellerException $e) {}
        return (empty($retVal)) ? $qname : $retVal;
    }