Allow config files to be generated by a set of foaf files in a directory

This commit is contained in:
Sam Ruby 2007-08-22 15:38:15 -04:00
parent d025fe59ac
commit 843a42b982

View File

@ -35,13 +35,13 @@ def load_model(rdf, base_uri):
return model return model
# input = foaf, output = ConfigParser # 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(): if not config or not config.sections():
return return
# there should be only be 1 section # there should be only be 1 section
section = config.sections().pop() if not section: section = config.sections().pop()
try: try:
from RDF import Model, NS, Parser, Statement from RDF import Model, NS, Parser, Statement
@ -191,6 +191,7 @@ if __name__ == "__main__":
for uri in sys.argv[1:]: for uri in sys.argv[1:]:
config.add_section(uri) config.add_section(uri)
foaf2config(urllib.urlopen(uri), config) foaf2config(urllib.urlopen(uri), config, section=uri)
config.remove_section(uri)
config.write(sys.stdout) config.write(sys.stdout)