Get all non-expired revealed namespaces.
424300
def namedb_get_all_revealed_namespace_ids( self, current_block ):
    
    
    query = "SELECT namespace_id FROM namespaces WHERE op = ? AND reveal_block < ?;"
    args = (NAMESPACE_REVEAL, current_block + NAMESPACE_REVEAL_EXPIRE )

    namespace_rows = namedb_query_execute( cur, query, args )
    ret = []
    for namespace_row in namespace_rows:
        ret.append( namespace_row['namespace_id'] )

    return ret
1268898
def _get_all_ns_packages(self):
        """"""
        pkgs = self.distribution.namespace_packages or []
        return sorted(flatten(map(self._pkg_names, pkgs)))
823163
public function getAllNamespaces()
    {
        $returnValue = array();

        
        
        if(count($this->namespaces) == 0){
        	$db = core_kernel_classes_DbWrapper::singleton();
        	$query = 'SELECT modelid, modeluri FROM models';
			$result = $db->query($query);
			
			while ($row = $result->fetch()){	
				$id 	= $row['modelid'];
				$uri 	= $row['modeluri'];
				$this->namespaces[$id] = $uri;
			}
        }
        
        foreach($this->namespaces as $id => $uri){
        	$returnValue[$uri] = new common_ext_Namespace($id, $uri);
        }

        

        return (array) $returnValue;
    }
1039309
def namedb_get_all_preordered_namespace_hashes( cur, current_block ):
    
    query = "SELECT preorder_hash FROM preorders WHERE op = ? AND block_number >= ? AND block_number < ?;"
    args = (NAMESPACE_PREORDER, current_block, current_block + NAMESPACE_PREORDER_EXPIRE )

    namespace_rows = namedb_query_execute( cur, query, args )
    ret = []
    for namespace_row in namespace_rows:
        ret.append( namespace_row['preorder_hash'] )

    return ret
1051005
private Map<String, String> namespaces(Kam kam) {
        Map<String, String> nsmap = new HashMap<String, String>();

        // find namespaces in resource index
        List<NamespaceDescriptor> ns = nsrsvc.getAllNamespaceDescriptors();
        for (NamespaceDescriptor n : ns) {
            Namespace the_ns = n.getNamespace();
            nsmap.put(the_ns.getPrefix(), the_ns.getResourceLocation());
        }

        // then find namespaces identified by the KAM
        List<org.openbel.framework.api.internal.KAMStoreDaoImpl.Namespace> nsl =
                kAMStore.getNamespaces(kam);
        for (org.openbel.framework.api.internal.KAMStoreDaoImpl.Namespace kam_ns : nsl) {
            nsmap.put(kam_ns.getPrefix(), kam_ns.getResourceLocation());
        }
        return nsmap;
    }
510586
private function findNamespaceAliases()
    {
        $namespaceAliases = [];

        // aliases can be only top-level nodes in the namespace, so we can scan them directly
        foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
            if ($namespaceLevelNode instanceof Use_) {
                $useAliases = $namespaceLevelNode->uses;
                if (!empty($useAliases)) {
                    foreach ($useAliases as $useNode) {
                        $namespaceAliases[$useNode->name->toString()] = $useNode->alias;
                    }
                }
            }
        }

        return $namespaceAliases;
    }
1120499
def collect_namespaces(metadata):
    # type: (Mapping[Text, Any]) -> Dict[Text, Text]
    """"""
    namespaces = {}  # type: Dict[Text, Text]
    if "$import_metadata" in metadata:
        for value in metadata["$import_metadata"].values():
            add_namespaces(collect_namespaces(value), namespaces)
    if "$namespaces" in metadata:
        add_namespaces(metadata["$namespaces"], namespaces)
    return namespaces
982924
private void checkNamespaces() {
    for (Name name : nameMap.values()) {
      if (name.isNamespaceObjectLit()
          && (name.getAliasingGets() > 0
              || name.getLocalSets() + name.getGlobalSets() > 1
              || name.getDeleteProps() > 0)) {
        boolean initialized = name.getDeclaration() != null;
        for (Ref ref : name.getRefs()) {
          if (ref == name.getDeclaration()) {
            continue;
          }

          if (ref.type == Ref.Type.DELETE_PROP) {
            if (initialized) {
              warnAboutNamespaceRedefinition(name, ref);
            }
          } else if (
              ref.type == Ref.Type.SET_FROM_GLOBAL
              || ref.type == Ref.Type.SET_FROM_LOCAL) {
            if (initialized && !isSafeNamespaceReinit(ref)) {
              warnAboutNamespaceRedefinition(name, ref);
            }

            initialized = true;
          } else if (ref.type == Ref.Type.ALIASING_GET) {
            warnAboutNamespaceAliasing(name, ref);
          }
        }
      }
    }
  }
1135984
public static Map<String, String> getNamespaces(final Session session) {
        final NamespaceRegistry registry = getNamespaceRegistry(session);
        final Map<String, String> namespaces = new HashMap<>();

        try {
            stream(registry.getPrefixes()).filter(internalPrefix.negate()).forEach(x -> {
                try {
                    namespaces.put(x, registry.getURI(x));
                } catch (final RepositoryException e) {
                    throw new RepositoryRuntimeException(e);
                }
            });
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
        return namespaces;
    }
484583
def namedb_get_namespace_reveal( cur, namespace_id, current_block, include_history=True ):
    

    select_query = "SELECT * FROM namespaces WHERE namespace_id = ? AND op = ? AND reveal_block <= ? AND ? < reveal_block + ?;"
    args = (namespace_id, NAMESPACE_REVEAL, current_block, current_block, NAMESPACE_REVEAL_EXPIRE)

    namespace_reveal_rows = namedb_query_execute( cur, select_query, args )

    namespace_reveal_row = namespace_reveal_rows.fetchone()
    if namespace_reveal_row is None:
        # no such reveal 
        return None 

    reveal_rec = {}
    reveal_rec.update( namespace_reveal_row )

    if include_history:
        hist = namedb_get_history( cur, namespace_id )
        reveal_rec['history'] = hist
    
    reveal_rec = op_decanonicalize('NAMESPACE_REVEAL', reveal_rec)
    return reveal_rec
172888
def get_namespace_statistics(self, namespace, start_offset, end_offset):
        """"""
        cursor = self.cursor
        cursor.execute('SELECT SUM(data_points), SUM(byte_count) '
                       'FROM gauged_statistics WHERE namespace = %s '
                       'AND offset BETWEEN %s AND %s',
                       (namespace, start_offset, end_offset))
        return [long(count or 0) for count in cursor.fetchone()]
1025128
@Override
  public Iterator<String> getPrefixes(String namespaceURI) {
    // per javax.xml.namespace.NamespaceContext doc
    if (namespaceURI == null)
      throw new IllegalArgumentException("Cannot find prefix for null namespace URI");

    List<String> list = new ArrayList<>();
    if (XMLConstants.XML_NS_URI.equals(namespaceURI))
      list.add(XMLConstants.XML_NS_PREFIX);
    else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI))
      list.add(XMLConstants.XMLNS_ATTRIBUTE);
    else
      for (Map.Entry<String, String> entry: bindings.entrySet()) {
        if (namespaceURI.equals(entry.getValue()))
          list.add(entry.getKey());
      }

    return Collections.unmodifiableList(list).iterator();
  }
10322
def GetNonExpiredApprovers(self):
    """"""

    lifetime = rdfvalue.Duration(
        self.Get(self.Schema.LIFETIME) or config.CONFIG["ACL.token_expiry"])

    # Check that there are enough approvers.
    #
    # TODO(user): approvals have to be opened with
    # age=aff4.ALL_TIMES because versioning is used to store lists
    # of approvers. This doesn't seem right and has to be fixed.
    approvers = set()
    now = rdfvalue.RDFDatetime.Now()
    for approver in self.GetValuesForAttribute(self.Schema.APPROVER):
      if approver.age + lifetime > now:
        approvers.add(utils.SmartStr(approver))

    return list(approvers)
747966
def get_namespace_by_keyword_version(self, keyword: str, version: str) -> Optional[Namespace]:
        """"""
        filt = and_(Namespace.keyword == keyword, Namespace.version == version)
        return self.session.query(Namespace).filter(filt).one_or_none()
796184
def get_all_revealed_namespace_ids( self ):
        
        cur = self.db.cursor()
        namespace_ids = namedb_get_all_revealed_namespace_ids( cur, self.lastblock )
        return namespace_ids
621178
def _GetBindingNamespace(self):
    """"""
    return (list(self.zeep_client.wsdl.bindings.itervalues())[0]
            .port_name.namespace)
204315
def namedb_get_all_namespace_ids( cur ):
    

    query = "SELECT namespace_id FROM namespaces WHERE op = ?;"
    args = (NAMESPACE_READY,)

    namespace_rows = namedb_query_execute( cur, query, args )
    ret = []
    for namespace_row in namespace_rows:
        ret.append( namespace_row['namespace_id'] )

    return ret