def read_rdf(sources, infmt):
rdf = Graph()<EOL>for source in sources:<EOL><INDENT>if isinstance(source, Graph):<EOL><INDENT>for triple in source:<EOL><INDENT>rdf.add(triple)<EOL><DEDENT>continue<EOL><DEDENT>if source == '<STR_LIT:->':<EOL><INDENT>f = sys.stdin<EOL><DEDENT>else:<EOL><INDENT>f = open(source, '<STR_LIT:r>')<EOL><DEDENT>if infmt:<EOL><INDENT>fmt = infmt<EOL><DEDENT>else:<EOL><INDENT>fmt = '<STR_LIT>'  <EOL>if source.endswith('<STR_LIT>'):<EOL><INDENT>fmt = '<STR_LIT>'<EOL><DEDENT>if source.endswith('<STR_LIT>'):<EOL><INDENT>fmt = '<STR_LIT>'<EOL><DEDENT>if source.endswith('<STR_LIT>'):<EOL><INDENT>fmt = '<STR_LIT>'<EOL><DEDENT><DEDENT>logging.debug("<STR_LIT>", source, fmt)<EOL>rdf.parse(f, format=fmt)<EOL><DEDENT>return rdf<EOL>
Read a list of RDF files and/or RDF graphs. May raise an Exception.