Converts the representation used to identify a text in the
        meta-data RDF graph to a human-friendly integer text identifier.
543093
def _uri_to_etext(cls, uri_ref):
        
        try:
            return validate_etextno(int(os.path.basename(uri_ref.toPython())))
        except InvalidEtextIdException:
            return None
1042377
function deentitify(s) {
    return s
        .replace(/&#(\d+);?/g, function (_, code) {
            return String.fromCharCode(code);
        })
        .replace(/&#[xX]([A-Fa-f0-9]+);?/g, function (_, hex) {
            return String.fromCharCode( parseInt(hex, 16) );
        })
        .replace(/&(\w+);/g, function (entity, name) {
            return entities[name] || entity;
        });
}
701442
def identifiers(dataset_uri):
    """"""
    dataset = dtoolcore.DataSet.from_uri(dataset_uri)
    for i in dataset.identifiers:
        click.secho(i)
472219
def type_converter(text):
    
    if text.isdigit():
        return int(text), int

    try:
        return float(text), float
    except ValueError:
        return text, STRING_TYPE
507290
function nodeFromDataToString(data, conversionContext) {
  var node = util.createElement(conversionContext.document, 'p');
  node.textContent = data.toString();
  return node;
}
741505
def dataset_from_rdf(graph, dataset=None, node=None):
    '''
    
    '''
    dataset = dataset or Dataset()

    if node is None:  # Assume first match is the only match
        node = graph.value(predicate=RDF.type, object=DCAT.Dataset)

    d = graph.resource(node)

    dataset.title = rdf_value(d, DCT.title)
    dataset.description = sanitize_html(d.value(DCT.description))
    dataset.frequency = frequency_from_rdf(d.value(DCT.accrualPeriodicity))

    acronym = rdf_value(d, SKOS.altLabel)
    if acronym:
        dataset.acronym = acronym

    tags = [tag.toPython() for tag in d.objects(DCAT.keyword)]
    tags += [theme.toPython() for theme in d.objects(DCAT.theme)]
    dataset.tags = list(set(tags))

    identifier = rdf_value(d, DCT.identifier)
    if identifier:
        dataset.extras['dct:identifier'] = identifier

    if isinstance(d.identifier, URIRef):
        dataset.extras['uri'] = d.identifier.toPython()

    dataset.temporal_coverage = temporal_from_rdf(d.value(DCT.temporal))

    licenses = set()
    for distrib in d.objects(DCAT.distribution | DCAT.distributions):
        resource_from_rdf(distrib, dataset)
        for predicate in DCT.license, DCT.rights:
            value = distrib.value(predicate)
            if isinstance(value, (URIRef, Literal)):
                licenses.add(value.toPython())
            elif isinstance(value, RdfResource):
                licenses.add(value.identifier.toPython())

    default_license = dataset.license or License.default()
    dataset.license = License.guess(*licenses, default=default_license)

    return dataset
1238395
def p_identifier_name_string(self, p):
        
        p[0] = asttypes.PropIdentifier(p[1].value)
        # manually clone the position attributes.
        for k in ('_token_map', 'lexpos', 'lineno', 'colno'):
            setattr(p[0], k, getattr(p[1], k))
1313153
def rdf_source(self, aformat="turtle"):
		
		if aformat and aformat not in self.SUPPORTED_FORMATS:
			return "Sorry. Allowed formats are %s" % str(self.SUPPORTED_FORMATS)
		if aformat == "dot":
			return self.__serializedDot()
		else:
			# use stardard rdf serializations
			return self.rdflib_graph.serialize(format=aformat)
462263
def transform_literals(rdf, literalmap):
    """"""

    affected_types = (SKOS.Concept, SKOS.Collection,
                      SKOSEXT.DeprecatedConcept)

    props = set()
    for t in affected_types:
        for conc in rdf.subjects(RDF.type, t):
            for p, o in rdf.predicate_objects(conc):
                if isinstance(o, Literal) \
                   and (p in literalmap or not in_general_ns(p)):
                    props.add(p)

    for p in props:
        if mapping_match(p, literalmap):
            newval = mapping_get(p, literalmap)
            newuris = [v[0] for v in newval]
            logging.debug("transform literal %s -> %s", p, str(newuris))
            replace_predicate(
                rdf, p, newuris, subjecttypes=affected_types)
        else:
            logging.info("Don't know what to do with literal %s", p)
559544
def _parse_value(self, el):
        """"""
        if el.find(RDF_NS + 'Bag') is not None:
            value = []
            for li in el.findall(RDF_NS + 'Bag/' + RDF_NS + 'li'):
                value.append(li.text)
        elif el.find(RDF_NS + 'Seq') is not None:
            value = []
            for li in el.findall(RDF_NS + 'Seq/' + RDF_NS + 'li'):
                value.append(li.text)
        elif el.find(RDF_NS + 'Alt') is not None:
            value = {}
            for li in el.findall(RDF_NS + 'Alt/' + RDF_NS + 'li'):
                value[li.get(XML_NS + 'lang')] = li.text
        else:
            value = el.text
        return value
533097
def wants_rdf(self, accepts):
		
		mimetype = mimeparse.best_match(all_mimetypes + self.all_mimetypes + [WILDCARD], accepts)
		return mimetype and mimetype != WILDCARD
1364226
def rdf2dot( g, stream, opts={} ):
    

    accept_lang = set( opts.get('lang',[]) )
    do_literal = opts.get('literal')
    nodes = {}
    links = []

    def node_id(x):
        if x not in nodes:
            nodes[x] = "node%d" % len(nodes)
        return nodes[x]

    def qname(x, g):
        try:
            q = g.compute_qname(x)
            return q[0] + ":" + q[2]
        except:
            return x

    def accept( node ):
        if isinstance( node, (rdflib.URIRef,rdflib.BNode) ):
            return True
        if not do_literal:
            return False
        return (not accept_lang) or (node.language in accept_lang)


    stream.write( u'digraph { \n node [ fontname="DejaVu Sans,Tahoma,Geneva,sans-serif" ] ; \n' )

    # Write all edges. In the process make a list of all nodes
    for s, p, o in g:
        # skip triples for labels
        if p == rdflib.RDFS.label:
            continue

        # Create a link if both objects are graph nodes
        # (or, if literals are also included, if their languages match)
        if not (accept(s) and accept(o)):
            continue

        # add the nodes to the list
        sn = node_id(s)
        on = node_id(o)

        # add the link
        q = qname(p,g)
        if isinstance(p, rdflib.URIRef):
            opstr = u'\t%s -> %s [ arrowhead="open", color="#9FC9E560", fontsize=9, fontcolor="#204080", label="%s", href="%s", target="_other" ] ;\n' % (sn,on,q,p)
        else:
            opstr = u'\t%s -> %s [ arrowhead="open", color="#9FC9E560", fontsize=9, fontcolor="#204080", label="%s" ] ;\n'%(sn,on,q)
        stream.write( opstr )

    # Write all nodes
    for u, n in nodes.items():
        lbl = escape( label(u,g,accept_lang), True )
        if isinstance(u, rdflib.URIRef):
            opstr = u'%s [ shape=none, fontsize=10, fontcolor=%s, label="%s", href="%s", target=_other ] \n' % (n, 'blue', lbl, u )
        else:
            opstr = u'%s [ shape=none, fontsize=10, fontcolor=%s, label="%s" ] \n' % (n, 'black', lbl )
        stream.write( u"# %s %s\n" % (u, n) )
        stream.write( opstr )

    stream.write(u'}\n')
473968
def _text_repr(text, max_len=1000):
    
    if text is None:
        text_repr = 'None'
    elif len(text) > max_len:
        text_repr = repr(text[0:max_len]) + '...'
    else:
        text_repr = repr(text)
    return text_repr
246142
def rdf_suffix(fmt: str) -> str:
    
    for k, v in SUFFIX_FORMAT_MAP.items():
        if fmt == v:
            return k
    return 'rdf'
813648
def convert_representation(self, i):
        
        if self.number_representation == 'unsigned':
            return i
        elif self.number_representation == 'signed':
            if i & (1 << self.interpreter._bit_width - 1):
                return -((~i + 1) & (2**self.interpreter._bit_width - 1))
            else:
                return i
        elif self.number_representation == 'hex':
            return hex(i)
1338488
def _rdf_graph_from_ntriples_string(ntriples_string, graph=nil)
      graph ||= RDF::Graph.new
      RDF::Reader.for(:ntriples).new(ntriples_string) do |reader|
        reader.each_statement do |statement|
          graph << statement
        end
      end
      graph
    end
852598
def rdf(self, rdf: Optional[Union[str, Graph]]) -> None:
        
        if isinstance(rdf, Graph):
            self.g = rdf
        else:
            self.g = Graph()
            if isinstance(rdf, str):
                if '\n' in rdf or '\r' in rdf:
                    self.g.parse(data=rdf, format=self.rdf_format)
                elif ':' in rdf:
                    self.g.parse(location=rdf, format=self.rdf_format)
                else:
                    self.g.parse(source=rdf, format=self.rdf_format)