Index: _4rdf.py =================================================================== RCS file: /var/local/cvsroot/4Suite/Ft/Rdf/_4rdf.py,v retrieving revision 1.33 diff -u -b -r1.33 _4rdf.py --- _4rdf.py 22 May 2005 03:29:16 -0000 1.33 +++ _4rdf.py 22 May 2005 03:42:20 -0000 @@ -1,5 +1,5 @@ ######################################################################## -# $Header: /var/local/cvsroot/4Suite/Ft/Rdf/_4rdf.py,v 1.33 2005/05/22 03:29:16 cogbuji Exp $ +# $Header: /var/local/cvsroot/4Suite/Ft/Rdf/_4rdf.py,v 1.32 2005/03/13 17:17:22 cogbuji Exp $ """ Implementation of '4rdf' command (functions defined here are used by the Ft.Lib.CommandLine framework) @@ -18,6 +18,7 @@ from Ft.Rdf import Model, RDF_MS_BASE, RDF_SCHEMA_BASE, DAML_OIL_NS, OWL_NS, OLD_DAML_OIL_NS from Ft.Rdf.Serializers.Dom import Serializer as DomSerializer from Ft.Rdf.Serializers.NTriples import Serializer as NTSerializer +from Ft.Rdf.Serializers.N3 import Serializer as N3Serializer from Ft.Xml.Domlette import NonvalidatingReader, PrettyPrint from Ft.Xml.InputSource import DefaultFactory @@ -95,6 +96,20 @@ sys.stderr.flush() return + elif in_format == "n3": + serializer = N3Serializer() + for source_arg in source_args: + try: + source_isrc = SourceArgToInputSource(source_arg, DefaultFactory) + suri = suri or source_isrc.uri + serializer.deserialize(m, source_isrc, suri) + CloseStream(source_isrc, quiet=True) + except Exception, e: + sys.stderr.write(str(e)+'\n') + sys.stderr.flush() + return + + if dump: stmts = m.complete(None, None, None) sys.stderr.write('The following is a list of remaining tuples, each in the form' \ @@ -298,7 +313,7 @@ #http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2001May/0264 Options.Option(None, 'input-format=FORMAT', - 'The format of the input file, can be "rdfxml" (the default) or "ntriples"'), + 'The format of the input file, can be "rdfxml" (the default), "n3", or "ntriples"'), #Options.Option('p', # 'dump-p', # 'Dump the resulting triples from the specified file or database '\ @@ -350,7 +365,7 @@ self.function = Run self.arguments = [ Arguments.ZeroOrMoreArgument('source', - 'The URI of an RDF/XML or N-Triples document, or "-" to indicate standard input.', + 'The URI of an RDF/XML, N3, or N-Triples document, or "-" to indicate standard input.', str), ]