#!/usr/bin/env python3 import json base_object = { "objects": { "object": [ { "source": { "id": "RIPE" }, "attributes": { "attribute": [ { "name": "mnt-by", "value": "mnt-ungleich" }, { "name": "source", "value": "RIPE" } ] } } ] } } def gen_route6(route6, asn): obj = base_object.copy() asn_obj = { 'name': 'origin', 'value': asn } route6_obj = { 'name': 'origin', 'value': asn } obj['objects']['object'][0]['attributes']['attribute'].append(asn_obj) obj['objects']['object'][0]['attributes']['attribute'].append(route6_obj) return obj def to_json(obj): return json.dumps(obj, indent = 4) if __name__ == '__main__': for route6 in [ "2a0a:e5c0::/48" ]: print(to_json(gen_route6(route6, "AS213081")))