March 16, 2016
rdfpipe
¶
A commandline tool for parsing RDF in different formats and serializing the resulting graph to a chosen format.
-
rdfextras.tools.rdfpipe.
guess_format
(fpath, fmap=None)[source]¶ Guess RDF serialization based on file suffix. Uses
SUFFIX_FORMAT_MAP
unlessfmap
is provided. Examples:>>> guess_format('path/to/file.rdf') 'xml' >>> guess_format('path/to/file.owl') 'xml' >>> guess_format('path/to/file.ttl') 'n3' >>> guess_format('path/to/file.xhtml') 'rdfa' >>> guess_format('path/to/file.svg') 'rdfa' >>> guess_format('path/to/file.xhtml', {'xhtml': 'grddl'}) 'grddl'
This also works with just the suffixes, with or without leading dot, and regardless of letter case:
>>> guess_format('.rdf') 'xml' >>> guess_format('rdf') 'xml' >>> guess_format('RDF') 'xml'
-
rdfextras.tools.rdfpipe.
parse_and_serialize
(input_files, input_format, guess, outfile, output_format, ns_bindings, store_conn='', store_type='IOMemory')[source]¶
-
rdfextras.tools.rdfpipe.
_format_and_kws
(fmt)[source]¶ >>> _format_and_kws("fmt") ('fmt', {}) >>> _format_and_kws("fmt:+a") ('fmt', {'a': True}) >>> _format_and_kws("fmt:a") ('fmt', {'a': True}) >>> _format_and_kws("fmt:+a,-b") ('fmt', {'a': True, 'b': False}) >>> _format_and_kws("fmt:c=d") ('fmt', {'c': 'd'})