def replace_subject(rdf, fromuri, touri):
if fromuri == touri:<EOL><INDENT>return<EOL><DEDENT>for p, o in rdf.predicate_objects(fromuri):<EOL><INDENT>rdf.remove((fromuri, p, o))<EOL>if touri is not None:<EOL><INDENT>if not isinstance(touri, (list, tuple)):<EOL><INDENT>touri = [touri]<EOL><DEDENT>for uri in touri:<EOL><INDENT>rdf.add((uri, p, o))<EOL><DEDENT><DEDENT><DEDENT>
Replace occurrences of fromuri as subject with touri in given model.

    If touri=None, will delete all occurrences of fromuri instead.
    If touri is a list or tuple of URIRefs, all values will be inserted.