Collects and returns all inherited namespaces for a given object
327727
def collect_namespaces(object)
      return [] unless object.respond_to?(:inheritance_tree)

      nss = object.inheritance_tree(true)
      if object.respond_to?(:superclass)
        nss |= [P('Object')] if object.superclass != P('BasicObject')
        nss |= [P('BasicObject')]
      end

      nss
    end
3103
def gatherNamespaces(self):
        '''
        '''
        if self.usedNamespaces is not None:
            return

        self.logger.debug('gatherNamespaces')
        self.usedNamespaces = {}
            
        # Add all schemas defined in wsdl
        # to used namespace and to the Alias dict
        for schema in self._wsdl.types.values():
            tns = schema.getTargetNamespace()
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(schema), tns),)
            if self.usedNamespaces.has_key(tns) is False:
                self.usedNamespaces[tns] = []
            self.usedNamespaces[tns].append(schema)
            NAD.add(tns)
            
        # Add all xsd:import schema instances
        # to used namespace and to the Alias dict
        for k,v in SchemaReader.namespaceToSchema.items():
            self.logger.debug('Register schema(%s) -- TNS(%s)'\
                %(_get_idstr(v), k),)
            if self.usedNamespaces.has_key(k) is False:
                self.usedNamespaces[k] = []
            self.usedNamespaces[k].append(v)
            NAD.add(k)
174185
def namespace_bindings_from_defs(ns_defs)
      (ns_defs||[]).reduce({}) do |h,ns_def|
        h[ns_def.prefix||""] = ns_def.href
        h
      end
    end
1079427
static public Namespace gatherNamespaces(Document doc) {
   	NamespaceGatherer gatherer=new NamespaceGatherer();	
   	u.forAllStatementOrBundle(doc.getStatementOrBundle(), 
   	                          gatherer);
   	
   	Namespace ns=gatherer.getNamespace();
   	return ns;
    }
999313
def get_collection_for_cls_name(self, cls_name):
        
        for cls in self.classes:
            if cls.__name__ == cls_name:
                return self.classes[cls]['collection']
        raise AttributeError("Unknown class name: %s" % cls_name)
514938
function getNamespacedData(namespace, data){
        var namespacedData = {};
        for (var key in data){
            // key starts with namespace
            if (key.slice(0, namespace.length) == namespace){
                var namespacedKey = key.slice(namespace.length, key.length);
                namespacedKey = namespacedKey.charAt(0).toLowerCase() + namespacedKey.slice(1);
                namespacedData[namespacedKey] = data[key];
            }
        }

        return namespacedData;
    }
448934
function findRefObjectsByWildcardNamespace (ref, components) {
  const [ type ] = ref.split(':')

  const objects = components[type]
  return objects ? Object.values(objects) : null
}
867743
def from_namespace(cls, namespace):
        """"""
        config = cls()
        for slot in cls.__slots__:
            if slot.startswith('_'):
                slot = slot[1:]
            if not hasattr(namespace, slot):
                continue
            setattr(config, slot, getattr(namespace, slot))

        return config
521941
def get_instance namespace, classname=nil, properties={}
    case namespace
    when Openwsman::ObjectPath
      classname = namespace.classname
      properties = namespace.properties
      namespace = namespace.namespace
      uri = epr_uri_for(namespace, classname)
    when Openwsman::EndPointReference
      namespace.each do |k,v|
        properties[k] = v
      end
      classname = namespace.classname
      uri = namespace.resource_uri
      namespace = namespace.namespace
    else
      uri = epr_uri_for(namespace, classname)
    end
    @options.set_dump_request if Wbem.debug
    @options.cim_namespace = namespace if @product == :openwsman
    @options.selectors = properties unless properties.empty?
    STDERR.puts "@client.get(namepace '#{@options.cim_namespace}', props #{properties.inspect}, uri #{uri}" if Wbem.debug
    res = @client.get(@options, uri)
    raise Openwsman::Exception.new res if res.fault?
    Wbem::Instance.new self, Openwsman::EndPointReference.new(uri, "", properties), res
  end
255489
def _get_namespaces(apiserver_url, name=""):
    ''''''
    # Prepare URL
    url = "{0}/api/v1/namespaces/{1}".format(apiserver_url, name)
    # Make request
    ret = http.query(url)
    if ret.get("body"):
        return salt.utils.json.loads(ret.get("body"))
    else:
        return None
75791
def getprefixes(self):
        """"""
        namespaces = []
        for l in (self.params, self.types):
            for t,r in l:
                ns = r.namespace()
                if ns[1] is None: continue
                if ns[1] in namespaces: continue
                if Namespace.xs(ns) or Namespace.xsd(ns):
                    continue
                namespaces.append(ns[1])
                if t == r: continue
                ns = t.namespace()
                if ns[1] is None: continue
                if ns[1] in namespaces: continue
                namespaces.append(ns[1])
        i = 0
        namespaces.sort()
        for u in namespaces:
            p = self.nextprefix()
            ns = (p, u)
            self.prefixes.append(ns)
776985
def _inherit_from(context, uri, calling_uri):
    """"""

    if uri is None:
        return None
    template = _lookup_template(context, uri, calling_uri)
    self_ns = context['self']
    ih = self_ns
    while ih.inherits is not None:
        ih = ih.inherits
    lclcontext = context._locals({'next': ih})
    ih.inherits = TemplateNamespace("self:%s" % template.uri,
                                lclcontext,
                                template=template,
                                populate_self=False)
    context._data['parent'] = lclcontext._data['local'] = ih.inherits
    callable_ = getattr(template.module, '_mako_inherit', None)
    if callable_ is not None:
        ret = callable_(template, lclcontext)
        if ret:
            return ret

    gen_ns = getattr(template.module, '_mako_generate_namespaces', None)
    if gen_ns is not None:
        gen_ns(context)
    return (template.callable_, lclcontext)
295325
def namespace(self):
        """"""
        if not self._operation_calculated:
            self._operation_calculated = True
            self._extract_operation_and_namespace()

        return self._namespace
105871
def get_subclass_tree(cls, ensure_unique=True):
    """"""
    subclasses = []
    # cls.__subclasses__() fails on classes inheriting from type
    for subcls in type.__subclasses__(cls):
        subclasses.append(subcls)
        subclasses.extend(get_subclass_tree(subcls, ensure_unique))
    return list(set(subclasses)) if ensure_unique else subclasses
789458
def namedb_get_names_in_namespace( cur, namespace_id, current_block, offset=None, count=None ):
    

    unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )

    query = "SELECT name FROM name_records JOIN namespaces ON name_records.namespace_id = namespaces.namespace_id WHERE name_records.namespace_id = ? AND " + unexpired_query + " ORDER BY name "
    args = (namespace_id,) + unexpired_args

    offset_count_query, offset_count_args = namedb_offset_count_predicate( offset=offset, count=count )
    query += offset_count_query + ";"
    args += offset_count_args

    name_rows = namedb_query_execute( cur, query, tuple(args) )
    ret = []
    for name_row in name_rows:
        rec = {}
        rec.update( name_row )
        ret.append( rec['name'] )

    return ret
120105
def _get_base_class_names(frame):
    
    co, lasti = frame.f_code, frame.f_lasti
    code = co.co_code

    extends = []
    for (op, oparg) in op_stream(code, lasti):
        if op in dis.hasconst:
            if type(co.co_consts[oparg]) == str:
                extends = []
        elif op in dis.hasname:
            if dis.opname[op] == 'LOAD_NAME':
                extends.append(('name', co.co_names[oparg]))
            if dis.opname[op] == 'LOAD_ATTR':
                extends.append(('attr', co.co_names[oparg]))
            if dis.opname[op] == 'LOAD_GLOBAL':
                extends.append(('name', co.co_names[oparg]))

    items = []
    previous_item = []
    for t, s in extends:
        if t == 'name':
            if previous_item:
                items.append(previous_item)
            previous_item = [s]
        else:
            previous_item += [s]
    if previous_item:
        items.append(previous_item)
    return items
271913
private static NameSpace getEngineNameSpace(ScriptContext scriptContext) {
        Map<String, Object> engineView = new ScriptContextEngineView(scriptContext);
        NameSpace ns = (NameSpace) engineView.get(engineNameSpaceKey);

        if (!engineView.containsKey(engineNameSpaceKey)) {
            // Create a global namespace for the interpreter
            ns = new ExternalNameSpace(null/*parent*/, "javax_script_context", engineView);
            engineView.put(engineNameSpaceKey, ns);
        }

        return ns;
    }