fetch all xrefs for a prefix, e.g. CHEBI
493486
def fetchall_triples_xrefs(prefix):
    
    logging.info("fetching xrefs for: "+prefix)
    query = """
    SELECT * WHERE {{
    ?c <{p}> ?x
    }}
    """.format(p=prefixmap[prefix])
    bindings = run_sparql(query)
    rows = [(r['c']['value'], r['x']['value']) for r in bindings]
    return rows
410572
def build_prefixes(namespaces=None):
    
    if namespaces is None:
        namespaces = [
            ('bf', str(BIBFRAME)),
            ('schema', str(SCHEMA_ORG))
        ]
    output = "PREFIX {}: <{}>\n".format(
        namespaces[0][0],
        namespaces[0][1])
    if len(namespaces) == 1:
        return output
    else:
        for namespace in namespaces[1:]:
            output += "PREFIX  {}: <{}>\n".format(namespace[0], namespace[1])
    return output
357717
public static File [] getFilesWithPrefix(File dir, final String prefix) {
        FileFilter prefixFilter = new FileFilter() {
                public boolean accept(File pathname)
                {
                    return pathname.getName().toLowerCase().
                        startsWith(prefix.toLowerCase());
                }
            };
        return dir.listFiles(prefixFilter);
    }
760399
def source_roots(self, document_path):
        """"""
        files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
        return [os.path.dirname(setup_py) for setup_py in files]
494383
def get_abi3_suffix():
    """"""
    for suffix, _, _ in (s for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION):
        if '.abi3' in suffix:  # Unix
            return suffix
        elif suffix == '.pyd':  # Windows
            return suffix
40287
def show_xref(self, c_a):
        
        if c_a:
            ref_kind_map = {0: "Class instanciation", 1: "Class reference"}
            bytecode._PrintSubBanner("XREF From")

            xrefs_from = c_a.get_xref_from()
            for ref_class in xrefs_from:
                if ref_class.get_vm_class().get_name() == self.get_name():
                    continue
                for ref_kind, ref_method, ref_offset in xrefs_from[ref_class]:
                    bytecode._PrintDefault(ref_kind_map[ref_kind])
                    bytecode._PrintDefault(' ')
                    bytecode._PrintDefault(ref_method.get_name())
                    bytecode._PrintDefault(' @ 0x%x' % ref_offset)
                    bytecode._PrintDefault('\n')

            bytecode._PrintDefault('\n')

            bytecode._PrintSubBanner("XREF To")
            xrefs_to = c_a.get_xref_to()
            for ref_class in xrefs_to:
                if ref_class.get_vm_class().get_name() == self.get_name():
                    continue
                bytecode._PrintDefault(ref_class.get_vm_class().get_name())
                bytecode._PrintDefault(' -->\n')
                for ref_kind, ref_method, ref_offset in xrefs_to[ref_class]:
                    bytecode._PrintDefault(ref_kind_map[ref_kind])
                    bytecode._PrintDefault(' ')
                    bytecode._PrintDefault(ref_method.get_name())
                    bytecode._PrintDefault(' @ 0x%x' % ref_offset)
                    bytecode._PrintDefault('\n')
1188231
def getXMLNS(self, prefix=None):
        
        if prefix == XMLSchemaComponent.xml:
            return XMLNS.XML
        parent = self
        ns = self.attributes[XMLSchemaComponent.xmlns].get(prefix or\
                XMLSchemaComponent.xmlns_key)
        while not ns:
            parent = parent._parent()
            ns = parent.attributes[XMLSchemaComponent.xmlns].get(prefix or\
                    XMLSchemaComponent.xmlns_key)
            if not ns and isinstance(parent, WSDLToolsAdapter):
                if prefix is None:
                    return ''
                raise SchemaError, 'unknown prefix %s' %prefix
        return ns
1114024
def get_prefix(self):
        
        for key, value in self.pages_config.items():
            if not hasattr(value, '__iter__'):
                value = (value, )
            for item in value:
                if type(self.node) == item\
                        or type(self.node) == getattr(item, 'model', None):
                    return key
701642
def get_filename(self, prefix, url):
        
        return '{}.txt'.format(os.path.join(os.getcwd(), prefix, self.clean_url(url)))
1341925
def get_prefix(self):
        """"""
        prefix = self.bucket
        if self.prefix:
            prefix += self.delimiter + self.prefix
        return prefix
417803
def get_prefix_dir(archive):
    
    names = archive.namelist()
    shortest_name = sorted(names, key=len)[0]
    candidate_prefixes = [
        shortest_name[:length]
        for length in range(len(shortest_name), -1, -1)
    ]
    for prefix in candidate_prefixes:
        if all(name.startswith(prefix) for name in names):
            return prefix
    return ''
313046
def shapeRef_to_iriref(self, ref: ShExDocParser.ShapeRefContext) -> ShExJ.IRIREF:
        
        if ref.ATPNAME_NS():
            return ShExJ.IRIREF(self._lookup_prefix(ref.ATPNAME_NS().getText()[1:]))
        elif ref.ATPNAME_LN():
            prefix, local = ref.ATPNAME_LN().getText()[1:].split(':', 1)
            return ShExJ.IRIREF(self._lookup_prefix(prefix + ':') + (local if local else ""))
        else:
            return self.shapeexprlabel_to_IRI(ref.shapeExprLabel())
181851
def namespace_for_prefix(self, prefix):
        
        try:
            ni = self.__lookup_prefix(prefix)
        except PrefixNotFoundError:
            return None
        else:
            return ni.uri
79644
def fetch_aliases(self, seq_id, current_only=True, translate_ncbi_namespace=None):
        """"""
        return [dict(r) for r in self.find_aliases(seq_id=seq_id,
                                                   current_only=current_only,
                                                   translate_ncbi_namespace=translate_ncbi_namespace)]
1300615
def get_directories_with_extensions(self, start, extensions=None):
        
        return set([p.parent for ext in extensions for p in start.rglob(ext)])
950731
def get_prefixes(dirname: str, extension: str) -> List[str]:
    

    prefixes = []
    for root, _, filenames in os.walk(dirname):
        for filename in filenames:
            if filename.endswith(extension):
                # Then it's an input feature file and its prefix will
                # correspond to a training example
                prefixes.append(os.path.join(root, filename.split(".")[0]))
    return sorted(prefixes)
1056172
def _gen_te_xref(self, expr: Union[ShExJ.tripleExpr, ShExJ.tripleExprLabel]) -> None:
        
        if expr is not None and not isinstance_(expr, ShExJ.tripleExprLabel) and 'id' in expr and expr.id is not None:
            if expr.id in self.te_id_map:
                return
            else:
                self.te_id_map[self._resolve_relative_uri(expr.id)] = expr
        if isinstance(expr, (ShExJ.OneOf, ShExJ.EachOf)):
            for expr2 in expr.expressions:
                self._gen_te_xref(expr2)
        elif isinstance(expr, ShExJ.TripleConstraint):
            if expr.valueExpr is not None:
                self._gen_schema_xref(expr.valueExpr)