franz.openrdf.util package¶
Submodules¶
franz.openrdf.util.contexts module¶
Utilities related to context managers.
- 
franz.openrdf.util.contexts.output_to(target)[source]¶
- 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. 
franz.openrdf.util.strings module¶
- 
franz.openrdf.util.strings.encode_ntriple_string(string)[source]¶
- Return a unicode string escaped according to N-Triples canonical encoding rules. 
- 
franz.openrdf.util.strings.encode_ntriple_uri(uri)[source]¶
- Converts a string URI to ntriples by adding angle brackets and escaping special characters. 
- 
franz.openrdf.util.strings.literal(string)[source]¶
- 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. 
- 
franz.openrdf.util.strings.nodeid(string)[source]¶
- If string is a valid NTriples BNode reference, extract and return the node id. Otherwise return None. 
- 
franz.openrdf.util.strings.ntriples_unescape(text)[source]¶
- Decodes ntriples escape sequences in a string. - Actually decodes a superset of said sequences. 
- 
franz.openrdf.util.strings.to_bytes(text)[source]¶
- 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 
- 
franz.openrdf.util.strings.to_native_string(text)[source]¶
- 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 
