def prepare_nquads_for_template(nquads): changes = {} for q in nquads: ctx = changes.get(q['context'], {'prefix': get_prefix_from_uri(q['context'])}) sub = ctx.get(q['subject'], {'qname': get_qname(q['subject']), 'label': get_label(q['subject'])}) pred = sub.get(q['predicate'], {'qname': get_qname(q['predicate']), 'label': get_label(q['predicate']), 'values': []}) vals = pred.get('values') v = rdfstring2dict(q['object']) v['class'] = q['type'] v['id'] = q['id'] vals.append(v) sub[q['predicate']] = pred ctx[q['subject']] = sub changes[q['context']] = ctx return changes
def proposals(): proposals_ = get_proposals() for p in proposals_: c = get_changes(p['id']) adds = 0 rems = 0; subs = [] for x in c: if x['type'] == 'addition': adds += 1 else: rems += 1 s = {'subject': x['subject'], 'ontology': get_prefix_from_uri(x['context'])} if s not in subs: subs.append(s) p['additions'] = adds p['removals'] = rems p['subjects'] = subs return render_template('proposals.html', proposals=proposals_)