Formats a namespace and ending value into a python friendly format

    args:
        namespace: RdfNamespace or tuple in the format of (prefix, uri,)
        value: end value to attach to the namespace
768338
def pyuri_formatter(namespace, value):
    
    if namespace[0]:
        return "%s_%s" %(namespace[0], value)
    else:
        return "pyuri_%s_%s" % (base64.b64encode(bytes(namespace[1],
                                                       "utf-8")).decode(),
                                value)
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
823115
def namespace_from_url(url):
    
    parsed = urlparse(url)
    if parsed.hostname is None or parsed.hostname in ['localhost', 'localhost.localdomain'] or (
            _ipv4_re.search(parsed.hostname)):
        return None

    namespace = parsed.hostname.split('.')
    namespace.reverse()
    if namespace and not namespace[0]:
        namespace.pop(0)
    if namespace and namespace[-1] == 'www':
        namespace.pop(-1)
    return type(url)('.'.join(namespace))
647373
def setNamespaceAttribute(self, prefix, namespaceURI):
        '''
        
        '''
        self._setAttributeNS(XMLNS.BASE, 'xmlns:%s' %prefix, namespaceURI)
942796
def namespace(self):
        
        if self.prefix is None:
            return Namespace.default
        else:
            return self.resolvePrefix(self.prefix)
1321852
def get_namespace_and_tag(name):
        

        if isinstance(name, str):
            if name[0] == "{":
                uri, ignore, tag = name[1:].partition("}")
            else:
                uri = None
                tag = name
        else:
            uri = None
            tag = None
        return uri, tag
279271
def uri(self, element, namespace=None):
        ''

        if namespace is None:
            namespace = self.namespace

        return URIRef('%s#%s' % (namespace, element))
252283
def ensure_regex_namespace(self, keyword: str, pattern: str) -> Namespace:
        
        if pattern is None:
            raise ValueError('cannot have null pattern')

        namespace = self.get_namespace_by_keyword_pattern(keyword, pattern)

        if namespace is None:
            log.info('creating regex namespace: %s:%s', keyword, pattern)
            namespace = Namespace(
                keyword=keyword,
                pattern=pattern
            )
            self.session.add(namespace)
            self.session.commit()

        return namespace
579068
def namespace(self, value):
        
        if not isinstance(value, str):
            raise ValueError("Namespace must be a string")
        self._namespace = value
183762
def prefix_with_ns_if_necessary(name, name_ns, source_ns):
    # type: (typing.Text, ApiNamespace, ApiNamespace) -> typing.Text
    
    if source_ns == name_ns:
        return name
    return '{}.{}'.format(fmt_namespace(name_ns.name), name)
888480
def xmlns(source):
    
    namespaces = {}
    events=("end", "start-ns", "end-ns")
    for (event, elem) in iterparse(source, events):
        if event == "start-ns":
            prefix, ns = elem
            namespaces[prefix] = ns
        elif event == "end":
            break

    # Reset stream
    if hasattr(source, "seek"):
        source.seek(0)

    return namespaces
434404
def _fixNS(self, namespace):
        
        if namespace == OPENID_NS:
            if self._openid_ns_uri is None:
                raise UndefinedOpenIDNamespace('OpenID namespace not set')
            else:
                namespace = self._openid_ns_uri

        if namespace != BARE_NS and type(namespace) not in [str, unicode]:
            raise TypeError(
                "Namespace must be BARE_NS, OPENID_NS or a string. got %r"
                % (namespace,))

        if namespace != BARE_NS and ':' not in namespace:
            fmt = 'OpenID 2.0 namespace identifiers SHOULD be URIs. Got %r'
            warnings.warn(fmt % (namespace,), DeprecationWarning)

            if namespace == 'sreg':
                fmt = 'Using %r instead of "sreg" as namespace'
                warnings.warn(fmt % (SREG_URI,), DeprecationWarning,)
                return SREG_URI

        return namespace
111908
def _getPrefixURL(self, url):
        
        for prefix, namespace in self._rdfGraph.namespaces():
            if namespace.toPython() in url:
                return namespace
700977
def namespace(self, **context):
        
        context = orb.Context(**context)
        if context.forceNamespace:
            return context.namespace or self.__namespace
        else:
            return self.__namespace or context.namespace
932822
function (namespace) {
			var result,
				aNamespaceParts = namespace.split(".");

			if (aNamespaceParts[0] === "Org" && aNamespaceParts[1] === "OData") {
				result = '<a href="' + this.ANNOTATIONS_NAMESPACE_LINK + namespace + '.xml">' + namespace + '</a>';
			} else {
				result = namespace;
			}

			result = this._preProcessLinksInTextBlock(result);
			return result;
		}
583488
private static String formatProvide(String namespace) {
    StringBuilder sb = new StringBuilder();

    sb.append("goog.provide('");
    sb.append(namespace);
    sb.append("');");

    return sb.toString();
  }
656374
def exploded_namespace_declarations(ns)
      Hash[ns.map do |prefix, uri|
             if prefix==""
               ["xmlns", uri]
             else
               [[prefix, "xmlns"], uri]
             end
           end]
    end