#!/usr/bin/python2.4

#
# A trivial tool for printing the content of a Strap graph in RDF/XML.
#

#
# (c)2005 LIRIS - University Claude Bernard Lyon 1
# http://liris.cnrs.fr/
#
# Author: Pierre-Antoine CHAMPIN
# http://champin.net/
#
# This software is distributed under the terms of the GNU LGPL v2.1.
# See LICENSE.txt for more details.
#

from rdflib                   import Graph
from strap.rdflib_impl.client import StrapBackend
from sys                      import argv, exit

def fail():
    print """
usage: strapdump.py <url or path>

Dump an RDF graph as RDF/XML from a strap server.
The argument is either a strap:// URL, or a file:/// URL or path to a unix
socket on which a strap server is listening.

example:
    strapdump.py strap://localhost:1234/path/to/graph
    strapdump.py /tmp/strap.sock
"""
    exit (-1)

if len (argv) != 2 or argv[1] in ("-?", "-h", "--help"):
    fail()

g = Graph (StrapBackend (argv[1]))
print g.serialize()
