#!/usr/bin/python2.4

#
# A trivial tool for feeding a Strap graph with the content of an RDF file.
#

#
# (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: strapclean.py <url or socket_path> <rdffile_path_or_url>

Feed an RDF graph to a strap server.
The first 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 my_file.rdf
    strapdump.py /tmp/strap.sock my_file.rdf
"""
    exit (-1)

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

g = Graph()
g.parse (argv[2])

h = Graph(StrapBackend (argv[1]))

for t in g.triples ((None, None, None)):
    h.remove (t)
