def materialize_entity(ctx, etype, unique=None):
    '''
    Low-level routine for creating a BIBFRAME resource. Takes the entity (resource) type and a data mapping
    according to the resource type. Implements the Libhub Resource Hash Convention
    As a convenience, if a vocabulary base is provided in the context, concatenate it to etype and the data keys

    ctx - context information governing creation of the new entity
    etype - type IRI for th enew entity
    unique - list of key/value tuples of data to use in generating its unique ID, or None in which case one is just randomly generated
    '''
    params = {}
    if ctx.base:
        etype = ctx.base + etype

    unique_computed = []
    for k, v in unique:
        k = k if iri.is_absolute(k) else iri.absolutize(k, ctx.base)
        v = v(ctx) if callable(v) else v
        unique_computed.append((k, v))

    if unique_computed:
        plaintext = json.dumps([etype, unique_computed], cls=OrderedJsonEncoder)
        eid = ctx.idgen.send(plaintext)
    else:
        #We only have a type; no other distinguishing data. Generate a random hash
        eid = next(ctx.idgen)
    return eid
def materialize_entity ( ctx , etype , unique = None ) : params = { } if ctx . base : etype = ctx . base + etype unique_computed = [ ] for k , v in unique : k = k if iri . is_absolute ( k ) else iri . absolutize ( k , ctx . base ) v = v ( ctx ) if callable ( v ) else v unique_computed . append ( ( k , v ) ) if unique_computed : plaintext = json . dumps ( [ etype , unique_computed ] , cls = OrderedJsonEncoder ) eid = ctx . idgen . send ( plaintext ) else : eid = next ( ctx . idgen ) return eid
Low-level routine for creating a BIBFRAME resource. Takes the entity (resource) type and a data mapping
    according to the resource type. Implements the Libhub Resource Hash Convention
    As a convenience, if a vocabulary base is provided in the context, concatenate it to etype and the data keys

    ctx - context information governing creation of the new entity
    etype - type IRI for th enew entity
    unique - list of key/value tuples of data to use in generating its unique ID, or None in which case one is just randomly generated