franz.openrdf.util package


franz.openrdf.util.contexts module

Utilities related to context managers.


Returns a file-like object constructed from target.

Target can be:

  • None: the returned stream will ignore all data
  • True: data will be written to stdout.
  • a string: a file will be opened (in binary mode)
  • a file-like object: will be returned as is.
  • an int - a file descriptor.
Parameters:target – File path, None or a file-like object.

Wrap a no-op context around an arbitrary value, so that it can be used in a with statement.

Parameters:value – Value to be returned by the context manager.
Returns:A context manager wrapping value.

franz.openrdf.util.strings module


Return a unicode string escaped according to N-Triples canonical encoding rules.


Converts a string URI to ntriples by adding angle brackets and escaping special characters.


If string is a valid literal in NTriples syntax, return its value, lang tag and type. Use None if there is no language tag or no datatype. If string is not a valid literal return None.


If string is a valid NTriples BNode reference, extract and return the node id. Otherwise return None.


Decodes ntriples escape sequences in a string.

Actually decodes a superset of said sequences.


If TEXT is a Unicode string, return a byte string in utf-8. Otherwise simply return TEXT.

Parameters:text (str|bytes|unicode) – Text to be converted.
Return type:bytes

Converts text to the native string type of the Python version used. UTF-8 encoding is used if the text needs to be encoded or decoded.

Parameters:text (str|bytes|unicode) – Text to be converted (either Unicode or bytes).
Return type:str

Converts a Match object representing a single character into an ntriple escape sequence.


If string is a valid NTriples URI reference, extract and return the URI (as a string). Otherwise return None.

franz.openrdf.util.uris module


Module contents