def test_uriref_syntax(): for testuri in good_uri_references: assert 1 == iri.matches_uri_ref_syntax( testuri ), "Good URI ref: '%s' Mistakenly tests as invalid" % repr(testuri) for testuri in bad_uri_references: assert 0 == iri.matches_uri_ref_syntax( testuri ), "Bad URI ref: '%s' Mistakenly tests as valid" % repr(testuri)
def __new__(cls, value): if not iri.matches_uri_ref_syntax(value): raise ValueError(_('Invalid IRI reference: "{0}"'.format(value))) self = super(iriref, cls).__new__(cls, value) # self = unicode, cls).__new__(cls, value) # optionally do stuff to self here return self
def __new__(cls, value): if not iri.matches_uri_ref_syntax(value): raise ValueError(_('Invalid IRI reference: "{0}"'.format(value))) self = super(iriref, cls).__new__(cls, value) #self = unicode, cls).__new__(cls, value) # optionally do stuff to self here return self
def zoom_in_(m, f, d, relcount): for o, r, t, a in m.match(f): relcount += 1 if max_rels and relcount > max_rels: return False, relcount zoomed.add(o, r, t, a) # XXX For now the Versa dump does not differentiate IRI targets # So we have to use an IRI ref syntax check, which is a bit awkward # if d and isinstance(t, I): if d and isinstance(t, str) and iri.matches_uri_ref_syntax(t): c, rc = zoom_in_(m, t, d-1, relcount) relcount += rc return True, relcount
def iri_ref_tool(m): body = m.group(1) lchar = '<' if iri.matches_uri_ref_syntax(body) else '<' return lchar + m.group(1) + '>'
def test_uriref_syntax(): for testuri in good_uri_references: assert 1 == iri.matches_uri_ref_syntax(testuri), "Good URI ref: '%s' Mistakenly tests as invalid" % repr(testuri) for testuri in bad_uri_references: assert 0 == iri.matches_uri_ref_syntax(testuri), "Bad URI ref: '%s' Mistakenly tests as valid" % repr(testuri)