from rdflib.Identifier import Identifier

node_id = 0
class BNode(Identifier):
    def __new__(cls):
        global node_id
        node_id += 1
        value = "_:a%s" % node_id
        return Identifier.__new__(cls, value)
        
    def n3(self):
        return str(self)

def n3(value):
    if value[0] == '"' and value[-1] == '"':
        return Literal(value[1:-1])
    else:
        return URIRef(value[1:-1])

