Example #1
0
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)
Example #2
0
 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
Example #3
0
 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
Example #4
0
 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
Example #5
0
 def iri_ref_tool(m):
     body = m.group(1)
     lchar = '&lt;' if iri.matches_uri_ref_syntax(body) else '<'
     return lchar + m.group(1) + '>'
Example #6
0
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)