Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def handle_role(node) :
if node.hasAttribute("role") :
old_values = node.getAttribute("role").strip().split()
new_values = ""
for val in old_values :
if termname.match(val) :
new_values += XHTML_URI + val + ' '
else :
new_values += val + ' '
node.setAttribute("role", new_values.strip())
def _massage_node(node,attr) :
"""The real work for remove_rel is done here, parametrized with @rel and @rev"""
if node.hasAttribute("property") and node.hasAttribute(attr) :
vals = node.getAttribute(attr).strip().split()
if len(vals) != 0 :
final_vals = [ v for v in vals if not termname.match(v) ]
if len(final_vals) == 0 :
node.removeAttribute(attr)
else :
node.setAttribute(attr, reduce(lambda x,y: x+' '+y,final_vals))
def _TERMorCURIEorAbsURI(self, val) :
"""Returns a URI either for a term or for a CURIE. The value must be an NCNAME to be handled as a term; otherwise
the method falls back on a CURIE or an absolute URI.
@param val: attribute value to be interpreted
@type val: string
@return: an RDFLib URIRef instance or None
"""
from . import uri_schemes
# This case excludes the pure base, ie, the empty value
if val == "" :
return None
from .termorcurie import ncname, termname
if termname.match(val) :
# This is a term, must be handled as such...
retval = self.term_or_curie.term_to_URI(val)
if not retval :
self.options.add_warning(err_undefined_terms % val, UnresolvableTerm, node=self.node.nodeName, buggy_value = val)
return None
else :
return retval
else :
# try a CURIE
retval = self.term_or_curie.CURIE_to_URI(val)
if retval :
return retval
elif self.rdfa_version >= "1.1" :
# See if it is an absolute URI
scheme = urlsplit(val)[0]
if scheme == "" :