From 843a42b98251a769ebfafccd5315ace23a5dc445 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Wed, 22 Aug 2007 15:38:15 -0400 Subject: [PATCH] Allow config files to be generated by a set of foaf files in a directory --- planet/foaf.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/planet/foaf.py b/planet/foaf.py index eb981d1..6149c1f 100644 --- a/planet/foaf.py +++ b/planet/foaf.py @@ -35,13 +35,13 @@ def load_model(rdf, base_uri): return model # input = foaf, output = ConfigParser -def foaf2config(rdf, config, subject=None): +def foaf2config(rdf, config, subject=None, section=None): if not config or not config.sections(): return # there should be only be 1 section - section = config.sections().pop() + if not section: section = config.sections().pop() try: from RDF import Model, NS, Parser, Statement @@ -191,6 +191,7 @@ if __name__ == "__main__": for uri in sys.argv[1:]: config.add_section(uri) - foaf2config(urllib.urlopen(uri), config) + foaf2config(urllib.urlopen(uri), config, section=uri) + config.remove_section(uri) config.write(sys.stdout)